29
Pixels, Numbers, and Programs Geometric Distortions Geometric Distortions Steven L. Tanimoto Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ 1 Distortion

and Geometric Distortions - courses.cs.washington.edu...that can be used in encoding, encryption, anamorphosis, etc. Can be parameterized for movie transition effects. A nice framework

  • Upload
    others

  • View
    4

  • Download
    1

Embed Size (px)

Citation preview

  • Pixels, Numbers, and Programs

    Geometric DistortionsGeometric Distortions

    Steven L. Tanimoto

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ 1Distortion

  • Outline

    MotivationDefinitionsSample techniquesp q“Modulator” imagesPolar coordinatesMore techniquesMore techniques

    (anamorphosis is covered is a separate set of slides.)

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 2

  • Why Study Distortion?

    There are many interesting effects that fall under this tcategory

    Distortions lead the way to more drastic transformations that can be used in encoding encryption anamorphosisthat can be used in encoding, encryption, anamorphosis, etc.

    Can be parameterized for movie transition effects.p

    A nice framework in which to explore what PixelMath can do to an image.

    Better understanding of what might have happened, when we see a distorted image.

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 3

  • Definition

    A basic PixelMath distortion formula has the formSource1(fx(x,y), fy(x,y))

    where fx(x,y) and fy(x,y) are expressions that may involve either x, or y, or both.

    For example, S1(x-y/2, y) is a basic PixelMath distortion formula.

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 4

  • S1(x-y/2, y) produces a shear of the image.

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 5

  • 255-S1(x,y) is not a basic PixelMath distortion formula, because the 255 and “‐” are outside the S1.

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 6

  • Sample Techniques

    • Shear• Ripples• Stripe‐cut and shift• Circle cut and shift• Shift with wraparound• “Avoid line”

    All these are basic distortions as defined here.

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 7

  • Ripples

    S1(x + 10*sin(x/5) y)S1(x + 10*sin(x/5), y)

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 8

  • Stripe‐cut and shift

    S1(x, y + if (x mod 40)

  • Circle‐cut and shift

    S1(x, y + if (sqr(x‐w/2)+ sqr(y‐2*h/3)) 

  • Shift with wraparound

    S1((x +100)mod w,(y+100)mod h))S1((x +100)mod w,(y+100)mod h))

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 11

  • “Avoid line”

    S1(x + 500/(1+abs(x - w/2)), y)S1(x + 500/(1+abs(x w/2)), y)

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 12

  • Modulator Images

    By setting up a second source image with pixel values h di l ( h h b i hthat represent displacements (rather than brightness values), we gain greater expressive power.

    Th tt f di l t b d bit ilThe pattern of displacements can be made arbitrarily complicated, but implementing the distortion remains simpleremains simple.

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 13

  • Example use of Modulator Image

    • Modulator image of checkerboard for use in “Block‐cut and shift”cut and shift

    • Synthesize the checkerboard using this formula:  if {x mod 50 < 25} xor {y mod 50 < 25} then 50 else 0if {x mod 50 

  • Modulator image and result

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 15

  • Using a photo as a modulator

    • Interesting effects can be obtained by using the i i l h d l f h ioriginal photo or art as modulator for another image 

    or artificial pattern.

    L t’ d l t th M Li i h th• Let’s modulate the Mona Lisa using her as the modulator!

    • S1(x y+red1(x y)/10)• S1(x, y+red1(x,y)/10)

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 16

  • Mona Lisa: self modulated

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 17

  • Polar Coordinates

    • An alternative to cartesian coordinates• Makes rotations easy• Makes the use of circles easy• Enables a variety of creative possibilities

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 18

  • Polar Coords. (math)

    P (point of interest)

    = distance Pole

    = measure of the angle between the 

    from the pole to the point P

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion

    horizontal and ray from the pole to the point

    19

  • Polar Coords. in PixelMath

    P (pixel of interest)rhomax

    theta=/2

    theta

    rho

    theta=

    center theta=0

    theta

    theta= ‐

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion

    theta= ‐/2

    20

  • Polar formulas in PixelMath

    • S1(rho,theta)    ‐‐ identity• rho ‐‐ gradient from center• theta ‐‐ nearly invisible

    ( h )* /( * ) l d• (pi+theta)*255/(2*pi) ‐‐ angular gradient• RGB(rho*255/(w/2), (pi+theta)*40, 0)

    polar palette of red and green combinations‐‐ polar palette of red and green combinations.

    • rho ‐‐ gradient from center• HSV((theta+pi)/(2*pi) rho/(w/2) if rho

  • Palette of saturated colors

    HSV((theta+pi)/(2*pi)HSV((theta+pi)/(2*pi), rho/(w/2), 

    if rho

  • Polar Distortions

    Radial shift outward:Radial shift outward:S1(if rho

  • Polar Distortions (cont).

    Radial shift inward:Radial shift inward:S1(rho+100, theta)

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 24

  • Polar Distortions (cont).

    Rotation:Rotation:S1(rho, theta-pi/8)

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 25

  • Polar Distortions (cont).

    Angular scaling:Angular scaling:S1(rho, theta*2)

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 26

  • Polar Distortions (cont).

    Circular cut and rotate:Circular cut and rotate:S1(rho,

    theta + if floor(rho) mod 40

  • Polar Distortions (cont).

    Angular cut and shrink:Angular cut and shrink:S1(rho*if

    (floor((pi+theta)*10) d 4)

  • Summary

    • Geometric distortions of an image involve moving pixels around from where they were.

    • Formulas of the form S1(fx(x,y),fy(x,y)) or ( x( ,y), y( ,y))S1(frho(rho,theta),ftheta(rho,theta)) give basic distortions.

    • Modulator images can be helpful in creating complex distortions or special effectsdistortions or special effects.

    • Polar coordinates offer many creative possiblities.

    Pixels, Numbers, and Programs; © S. Tanimoto ‐‐ Distortion 29