Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y....

49
Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros
  • date post

    22-Dec-2015
  • Category

    Documents

  • view

    220
  • download

    2

Transcript of Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y....

Page 1: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Image warping/morphing

Digital Video Special Effects

Fall 2006

2006/10/17

with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros

Page 2: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Image warping

Page 3: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Image warping

image filtering: change range of image g(x) = h(f(x))f

x h

g

x

f

x

hg

x

image warping: change domain of image g(x) = f(h(x))

Page 4: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

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))

Page 5: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Parametric (global) warping

translation rotation aspect

affineperspective

cylindrical

Examples of parametric warps:

Page 6: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

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 just a few numbers (parameters)

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

T

p = (x,y)

p’ = (x’,y’)

y

x

y

xM

'

'

Page 7: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Scaling

Scaling a coordinate means multiplying each of its components by a scalar

Uniform scaling means this scalar is the same for all components:

2

Page 8: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Non-uniform scaling: different scalars per component:

Scaling

X 2,Y 0.5

Page 9: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Scaling

Scaling operation:

Or, in matrix form:

byy

axx

'

'

y

x

b

a

y

x

0

0

'

'

scaling matrix S

What’s inverse of S?

Page 10: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

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

cossin

sincos

'

'

TRR 1

R

Page 11: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

2x2 Matrices

What types of transformations can be represented with a 2x2 matrix?2D Identity?

yyxx

''

yx

yx

1001

''

2D Scale around (0,0)?

ysy

xsx

y

x

*'

*'

y

x

s

s

y

x

y

x

0

0

'

'

Page 12: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

2x2 Matrices

What types of transformations can be represented with a 2x2 matrix?

2D Rotate around (0,0)?

yxy

yxx

*cos*sin'

*sin*cos'

y

x

y

x

cossin

sincos

'

'

2D Shear?

yxshy

yshxx

y

x

*'

*'

y

x

sh

sh

y

x

y

x

1

1

'

'

Page 13: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

2x2 Matrices

What types of transformations can be represented with a 2x2 matrix?

2D Mirror about Y axis?

yyxx

''

yx

yx

1001

''

2D Mirror over (0,0)?

yyxx

''

yx

yx

1001

''

Page 14: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

All 2D Linear Transformations

Linear transformations are combinations of … Scale, Rotation, Shear, 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

dc

ba

y

x

'

'

Page 15: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

2x2 Matrices

What types of transformations can be represented with a 2x2 matrix?

2D Translation?

y

x

tyy

txx

'

'

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

NO!

Page 16: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Translation

Example of translation

11100

10

01

1

'

'

y

x

y

x

ty

tx

y

x

t

t

y

x

tx = 2ty = 1

Homogeneous Coordinates

Page 17: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

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

wyx

fedcba

wyx

100''

Page 18: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Projective Transformations Projective transformations …

Affine transformations, and Projective warps

Properties of projective 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

wyx

ihgfedcba

wyx

'''

Page 19: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

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.)

Page 20: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

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)

Page 21: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Forward warping

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

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

h(x)

Page 22: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Forward warping

Send 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, n

ormalize later (splatting)

Page 23: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

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’)

Page 24: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

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 interpolate

d (prefiltered) source image

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

Page 25: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Interpolation

Possible interpolation filters: nearest neighbor bilinear bicubic sinc / FIR

Page 26: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Bilinear interpolation

A simple method for resampling images

Page 27: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Non-parametric image warping Specify a more detailed warp function Splines, meshes, optical flow (per-pixel motion)

Page 28: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Demo

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

eo matching, view interpolation and so on.

Page 29: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Image morphing

Page 30: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Image morphing

The goal is to synthesize a fluid transformation from one image

to another.

image #1 image #2dissolving

Cross dissolving is a common transition between cuts, but it is not good for morphing because of the ghosting effects.

Page 31: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Artifacts of cross-dissolving

http://www.salavon.com/

Page 32: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Image morphing

Why ghosting? Morphing = warping + cross-dissolving

shape

(geometric)

color

(photometric)

Page 33: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

morphing

cross-dissolving

Image morphingimage #1 image #2

warp warp

Page 34: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Morphing sequence

Page 35: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Face averaging by morphing

average faces

Page 36: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Image morphing

create a morphing sequence: for each time t1. Create an intermediate warping field (by

interpolation)

2. Warp both images towards it

3. Cross-dissolve the colors in the newly warped images

Page 37: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

An ideal example

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

morphing

Page 38: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

An ideal example

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

Page 39: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Warp specification (mesh warping)

How can we specify the warp?1. Specify corresponding spline control points

interpolate to a complete warping function

easy to implement, but less expressive

Page 40: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Warp specification (field warping)

How can we specify the warp?2. Specify corresponding vectors

• interpolate to a complete warping function• The Beier & Neely Algorithm

Page 41: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Beier&Neely (SIGGRAPH 1992)

Single line-pair PQ to P’Q’:

Page 42: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

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’)

Page 43: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Multiple Lines

length = length of the line segment, dist = distance to line segmentThe influence of a, p, b. The same as the average of Xi’

Page 44: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Full Algorithm

Page 45: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Resulting warp

Page 46: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Comparison to mesh morphing

Pros: more expressive Cons: speed and control

Page 47: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

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

orientation anglet=0

t=1

Page 48: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

Multi-source morphing

Page 49: Image warping/morphing Digital Video Special Effects Fall 2006 2006/10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.

References

George Wolberg, Image morphing: a survey, The Visual Computer, 1998, pp360-372.

Thaddeus Beier, Shawn Neely. Feature-Based Image Metamorphosis, SIGGRAPH 1992.

Michael Jackson's "Black or White" MTV