Image warping/morphing Digital Visual Effects, Spring 2006 Yung-Yu - - PowerPoint PPT Presentation

image warping morphing
SMART_READER_LITE
LIVE PREVIEW

Image warping/morphing Digital Visual Effects, Spring 2006 Yung-Yu - - PowerPoint PPT Presentation

Image warping/morphing Digital Visual Effects, Spring 2006 Yung-Yu Chuang 2005/3/15 with slides by Richard Szeliski, Steve Seitz and Alexei Efros Outline Images Image warping Image morphing Image fundamentals B A Image


slide-1
SLIDE 1

Image warping/morphing

Digital Visual Effects, Spring 2006 Yung-Yu Chuang 2005/3/15

with slides by Richard Szeliski, Steve Seitz and Alexei Efros

slide-2
SLIDE 2

Outline

  • Images
  • Image warping
  • Image morphing
slide-3
SLIDE 3

Image fundamentals

slide-4
SLIDE 4

Image formation

A B

slide-5
SLIDE 5

Sampling and quantization

slide-6
SLIDE 6

What is an image

  • We can think of an image as a function, f: R

2R:

– f(x, y) gives the intensity at position (x, y) – defined over a rectangle, with a finite range:

  • f: [a,b]x[c,d] [0,1]
  • A color image

( , ) ( , ) ( , ) ( , ) r x y f x y g x y b x y ⎡ ⎤ ⎢ ⎥ = ⎢ ⎥ ⎢ ⎥ ⎣ ⎦

x y f

slide-7
SLIDE 7

A digital image

  • We usually operate on digital (discrete) images:

– Sample the 2D space on a regular grid – Quantize each sample (round to nearest integer)

  • If our samples are D apart, we can write this as:

f[i ,j ] = Quantize{ f(i D, j D) }

  • The image can now be represented as a matrix
  • f integer values

62 79 23 119 120 105 4 10 10 9 62 12 78 34 10 58 197 46 46 48 176 135 5 188 191 68 49 2 1 1 29 26 37 77 89 144 147 187 102 62 208 255 252 166 123 62 31 166 63 127 17 1 99 30

slide-8
SLIDE 8

Image warping

slide-9
SLIDE 9

Image warping

image filtering: change range of image

g(x) = h(f(x))

f x

h

g x f x

h

g x

image warping: change domain of image

g(x) = f(h(x))

slide-10
SLIDE 10

Image warping

h h

f f g g

image filtering: change range of image

f(x) = h(g(x))

image warping: change domain of image

f(x) = g(h(x))

slide-11
SLIDE 11

Parametric (global) warping

translation rotation aspect affine perspective cylindrical

Examples of parametric warps:

slide-12
SLIDE 12

Parametric (global) warping

  • Transformation T is a coordinate-changing

machine: p’ = T(p)

  • What does it mean that T is global?

– Is the same for any point p – can be described by j ust a few numbers (parameters)

  • Represent T as a matrix: p’ = M*p

T p = (x,y) p’ = (x’,y’)

⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ y x y x M ' '

slide-13
SLIDE 13

Scaling

  • S

caling a coordinate means multiplying each of

its components by a scalar

  • Uniform scaling means this scalar is the same

for all components:

× 2

slide-14
SLIDE 14
  • Non-uniform scaling: different scalars per

component:

Scaling

X × 2, Y × 0.5

slide-15
SLIDE 15

Scaling

  • S

caling operation:

  • Or, in matrix form:

by y ax x = = ' ' ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ y x b a y x ' '

scaling matrix S What’s inverse of S?

slide-16
SLIDE 16

2-D Rotation

  • This is easy to capture in matrix form:
  • Even though sin(θ) and cos(θ) are nonlinear to θ,

– x’ is a linear combination of x and y – y’ is a linear combination of x and y

  • What is the inverse transformation?

– Rotation by –θ – For rotation matrices, det(R) = 1 so

( ) ( ) ( ) ( )

⎥ ⎦ ⎤ ⎢ ⎣ ⎡ ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ − = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ y x y x θ θ θ θ cos sin sin cos ' '

T

R R =

−1

R

slide-17
SLIDE 17

2x2 Matrices

  • What types of transformations can be

represented with a 2x2 matrix?

2D Identity?

y y x x = = ' ' ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ y x y x 1 1 ' '

2D Scale around (0,0)?

y s y x s x

y

x

* ' * ' = = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ y x s s y x

y x

' '

slide-18
SLIDE 18

2x2 Matrices

  • What types of transformations can be

represented with a 2x2 matrix?

2D Rotate around (0,0)?

y x y y x x * cos * sin ' * sin * cos ' θ θ θ θ + = − =

⎥ ⎦ ⎤ ⎢ ⎣ ⎡ ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ − = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ y x y x θ θ θ θ cos sin sin cos ' '

2D Shear?

y x sh y y sh x x

y x

+ = + = * ' * '

⎥ ⎦ ⎤ ⎢ ⎣ ⎡ ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ y x sh sh y x

y x

1 1 ' '

slide-19
SLIDE 19

2x2 Matrices

  • What types of transformations can be

represented with a 2x2 matrix?

2D Mirror about Y axis?

y y x x = − = ' '

⎥ ⎦ ⎤ ⎢ ⎣ ⎡ ⎥ ⎦ ⎤ ⎢ ⎣ ⎡− = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ y x y x 1 1 ' '

2D Mirror over (0,0)?

y y x x − = − = ' '

⎥ ⎦ ⎤ ⎢ ⎣ ⎡ ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ − − = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ y x y x 1 1 ' '

slide-20
SLIDE 20

All 2D Linear Transformations

  • Linear transformations are combinations of …

– S

cale,

– Rotation, – S

hear, and

– Mirror

  • Properties of linear transformations:

– Origin maps to origin – Lines map to lines – Parallel lines remain parallel – Ratios are preserved – Closed under composition

⎥ ⎦ ⎤ ⎢ ⎣ ⎡ ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ y x d c b a y x ' '

slide-21
SLIDE 21

2x2 Matrices

  • What types of transformations can be

represented with a 2x2 matrix?

2D Translation?

y x

t y y t x x + = + = ' '

Only linear 2D transformations can be represented with a 2x2 matrix

NO!

slide-22
SLIDE 22

Translation

  • Example of translation

⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ + + = ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ = ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ 1 1 1 1 1 1 ' '

y x y x

t y t x y x t t y x

tx = 2 ty = 1 Homogeneous Coordinates

slide-23
SLIDE 23

Affine Transformations

  • Affine transformations are combinations of …

– Linear transformations, and – Translations

  • Properties of affine transformations:

– Origin does not necessarily map to origin – Lines map to lines – Parallel lines remain parallel – Ratios are preserved – Closed under composition – Models change of basis

⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎣ ⎡ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎣ ⎡ = ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎣ ⎡ w y x f e d c b a w y x 1 ' '

slide-24
SLIDE 24

Projective Transformations

  • Proj ective transformations …

– Affine transformations, and – Proj ective warps

  • Properties of proj ective transformations:

– Origin does not necessarily map to origin – Lines map to lines – Parallel lines do not necessarily remain parallel – Ratios are not preserved – Closed under composition – Models change of basis

⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎣ ⎡ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎣ ⎡ = ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎣ ⎡ w y x i h g f e d c b a w y x ' ' '

slide-25
SLIDE 25

2D coordinate transformations

  • translation:

x’ = x + t x = (x,y)

  • rotation:

x’ = R x + t

  • similarity:

x’ = s R x + t

  • affine:

x’ = A x + t

  • perspective:

x’ ≅ H x x = (x,y,1)

(x is a homogeneous coordinate)

  • These all form a nested group (closed under

composition w/ inv.)

slide-26
SLIDE 26

Image warping

  • Given a coordinate transform x’ = h(x) and a

source image f(x), how do we compute a transformed image g(x’) = f(h(x))?

f(x) g(x’) x x’ h(x)

slide-27
SLIDE 27

Forward warping

  • S

end each pixel f(x) to its corresponding location x’ = h(x) in g(x’)

f(x) g(x’) x x’ h(x)

slide-28
SLIDE 28

Forward warping

  • S

end each pixel f(x) to its corresponding location x’ = h(x) in g(x’)

f(x) g(x’) x x’ h(x)

  • What if pixel lands “between” two pixels?
  • Answer: add “contribution” to several pixels,

normalize later (splatting)

slide-29
SLIDE 29

Inverse warping

  • Get each pixel g(x’) from its corresponding

location x = h-1(x’) in f(x)

f(x) g(x’) x x’ h-1(x’)

slide-30
SLIDE 30

Inverse warping

  • Get each pixel g(x’) from its corresponding

location x = h-1(x’) in f(x)

  • What if pixel comes from “between” two pixels?
  • Answer: resample color value from

interpolated (prefiltered) source image

f(x) g(x’) x x’

slide-31
SLIDE 31

Interpolation

  • Possible interpolation filters:

– nearest neighbor – bilinear – bicubic – sinc / FIR

slide-32
SLIDE 32

Bilinear interpolation

  • A simple method for resampling images
slide-33
SLIDE 33

Non-parametric image warping

  • S

pecify a more detailed warp function

  • S

plines, meshes, optical flow (per-pixel motion)

slide-34
SLIDE 34

Demo

  • http:/ / www.colonize.com/ warp/
  • Warping is a useful operation for mosaics, video

matching, view interpolation and so on.

slide-35
SLIDE 35

Image morphing

slide-36
SLIDE 36

Image morphing

  • The goal is to synthesize a fluid transformation

from one image to another. image #1 image #2 dissolving

  • Cross dissolving is a common transition between

cuts, but it is not good for morphing because of the ghosting effects.

slide-37
SLIDE 37

Artifacts of cross-dissolving

http:/ / www.salavon.com/

slide-38
SLIDE 38

Image morphing

  • Why ghosting?
  • Morphing = warping + cross-dissolving

shape (geometric) color (photometric)

slide-39
SLIDE 39

morphing cross-dissolving

Image morphing

image #1 image #2 warp warp

slide-40
SLIDE 40

Morphing sequence

slide-41
SLIDE 41

Face averaging by morphing

average faces

slide-42
SLIDE 42

Image morphing

create a morphing sequence: for each time t

  • 1. Create an intermediate warping field (by

interpolation)

  • 2. Warp both images towards it
  • 3. Cross-dissolve the colors in the newly warped

images

slide-43
SLIDE 43

An ideal example

t=0 t=1 t=0.25 t=0.5 t=0.75 morphing

slide-44
SLIDE 44

An ideal example

middle face (t=0.5) t=0 t=1

slide-45
SLIDE 45

Warp specification (mesh warping)

  • How can we specify the warp?
  • 1. S

pecify corresponding spline cont rol point s

int erpolat e to a complete warping function

easy to implement, but less expressive

slide-46
SLIDE 46

Warp specification (field warping)

  • How can we specify the warp?
  • 2. S

pecify corresponding vect ors

  • int erpolat e to a complete warping function
  • The Beier & Neely Algorithm
slide-47
SLIDE 47

Beier&Neely (SIGGRAPH 1992)

  • S

ingle line-pair PQ to P’Q’:

slide-48
SLIDE 48

Algorithm (single line-pair)

  • For each X in the destination image:
  • 1. Find the corresponding u,v
  • 2. Find X’ in the source image for that u,v
  • 3. destinationImage(X) = sourceImage(X’)
  • Examples:

Affine transformation

slide-49
SLIDE 49

Multiple Lines

length = length of the line segment, dist = distance to line segment

The influence of a, p, b. The same as the average of Xi’

slide-50
SLIDE 50

Full Algorithm

slide-51
SLIDE 51

Resulting warp

slide-52
SLIDE 52

Comparison to mesh morphing

  • Pros: more expressive
  • Cons: speed and control
slide-53
SLIDE 53

Warp interpolation

  • How do we create an intermediate warp at

time t?

– linear interpolation for line end-points – But, a line rotating 180 degrees will become 0

length in the middle

– One solution is to interpolate line mid-point and

  • rientation angle

t=0 t=1

slide-54
SLIDE 54

Animated sequences

  • S

pecify keyframes and interpolate the lines for the inbetween frames

  • Require a lot of tweaking
slide-55
SLIDE 55

Results

Michael Jackson’ s MTV “ Black or Whit e”

slide-56
SLIDE 56

Warp specification

  • How can we specify the warp
  • 3. S

pecify corresponding point s

  • int erpolat e to a complete warping function
slide-57
SLIDE 57

Solution#1: convert to mesh warping

  • 1. Define a triangular mesh over the points

– S

ame mesh in both images!

– Now we have triangle-to-triangle correspondences

  • 2. Warp each triangle separately from source to destination

– How do we warp a triangle? – 3 points = affine warp! – Just like texture mapping

slide-58
SLIDE 58

Multi-source morphing

slide-59
SLIDE 59

Multi-source morphing

slide-60
SLIDE 60

References

  • George Wolberg, Image morphing: a survey,

The Visual Computer, 1998, pp360-372.

  • Thaddeus Beier, S

hawn Neely. Feature-Based Image Metamorphosis, S IGGRAPH 1992.

  • Michael Jackson's "Black or White" MTV