8. image and view morphing - caig...

47
IMAGE-BASED MODELING AND RENDERING 8. IMAGE AND VIEW MORPHING I-Chen Lin, Dept. of CS, National Chiao Tung University

Upload: nguyenhuong

Post on 06-Sep-2018

270 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

IMAGE-BASED MODELING AND RENDERING

8. IMAGE AND VIEW MORPHING

I-Chen Lin, Dept. of CS, National Chiao Tung University

Page 2: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• Image Morphing

• View Morphing

Outline

Reference:

• Prof. S. Seitz and P. Heckbert (CMU), Image-based modeling and rendering course notes.

• T. Beier, S. Neely, "Feature Based Image Metamorphosis," Proc. SIGGRAPH'92, pp. 35-42, 1992.

• S. M. Seitz, C. R. Dyer, "View Morphing", Proc. SIGGRAPH’96, pp. 21-30.

Page 3: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• Rearranging pixels of a picture.

• It’s useful for both image processing and for computer graphics (namely, for texture mapping).

• Finding corresponding points in the source and destination images.

• This function is called the “mapping” or “transformation”.

Image Warping

Page 4: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• How to warp an image with a more complex function?

• If the source and destination is of structural similarity

• piecewise affine over a triangulation.

• piecewise projective over a quadrilaterization.

• piecewise bilinear over a rectangular grid.

More Complex Situations

Page 5: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• Arbitrary functions can be used.

• Store u[x,y] and v[x,y] in large arrays

• Learning techniques: e.g. neural network

• ………

• Popular methods in computer graphics:

• Beier-Neely warp (popular for image morphing)

• Radial-basis-function (RBF) based data scattering.

• ………

More Complex Situations …

Page 6: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• Short for “metamorphosis”.

• Early films used cross-dissolving only, but that looks artificial, non-physical.

• Morph = warp the shape + cross-dissolve the colors.

• If the mappings are defined, cross-dissolving can simply be performed by interpolation.

Morphing

Page 7: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

Proposed by Thaddeus Beier, Shawn Neely

Prof. ACM SIGGRAPH’92, pp. 35-42.

FEATURE-BASED IMAGE METAMORPHOSIS

Page 8: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• To transform one image smoothly into another image

Motivation

Page 9: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

Overview

Image warping

Image warping

Color Blending

Page 10: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• How to find a controllable mapping function with little manual assistance?

• What’s the problem of mesh-based warping tech.?

• How about the concept of “field”?

Concepts (Beier-Neely warp )

Page 11: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• Features

• Points

• Lines

• Curves

• ……

• Fields

• Linear

• quadratic

• ……

How to control the mapping?

Source destination

Using control lines

Page 12: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

With only one pair of lines

• To map the pixel X from pixel X' by corresponding lines PQ and P'Q'.

Page 13: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

With only one pair of lines

• Scan every pixels on the destination image and compute the corresponding pixels on the source image.

Page 14: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

An example (only one pair of lines)

Page 15: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• Transforms each pixel coordinate by a rotation, translation ,and/or scale.

• The image is scaled along the direction of lines by the ratio of the length of the line.

• Pure rotation and translation.

• Affine transformations. (uniform scales and shear are not possible to specify.)

The properties of this approach

Page 16: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

With multiple pairs of lines

• Specifying more complex transformations.

• The displacement Di = Xi’-X.

• A weighted average of these displacements is calculated.

Page 17: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

With multiple pairs of lines (cont.)

Page 18: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

For each pixel X in the destination

DSUM = (0,0)

weightsum = 0

For each line Pi Qi

calculate u,v based on Pi Qi

calculate X'i based on u,v and Pi'Qi'

calculate displacement Di = Xi' - Xi for this line

dist = shortest distance from X to Pi Qi

weight = (length^p / (a + dist))^b

DSUM += Di * weight

weightsum += weight

X' = X + DSUM / weightsum

destinationImage(X) = sourceImage(X')

With multiple pairs of lines (cont.)

Page 19: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

An example with two line pairs

Page 20: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

Morphing between two images

1. Assign the control lines.

2. CL(t) = (1-t)CL(0)+t CL(1)

3. Generate I0(t), I1(t) according to CL(t)

4. I(t) = (1-t)I0(t) + t I1(t)

Source

CL(0)

I(0)

Destination

CL(1)

I(1)

CL(t)

I0(t)

CL(t)

I1(t)

Page 21: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• Interpolating the endpoints of each line. • A rotating line would shrink.

• Interpolating the center position and orientation of each line. • This isn’t very obvious to the user, who might be surprised by how the lines

interpolate.

Two different ways of interpolating

source

destination

intermediate

Page 22: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• It’s much more expressive.

• The animator simply has to describe how lines in a source image are mapped into lines in a destination image.

• The mesh warping is much less intuitive.

Advantages

Page 23: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• This algorithm must compute the effect of every feature line on the movement of that pixel. slow!

• In contrast, mesh warping has only local control .

• Sometimes unexpected interpolations are generated.

• pixel may be far away from all lines.

Disadvantages

Page 24: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

Disadvantage (cont.)

• The algorithm might make a mistake in computing how that pixel should move during morphing.

Page 25: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• Need a set of line segments at key frames for each sequence.

Animated sequences

A sequence from Michael Jackson’s MTV “Black or White”

Page 26: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

Questions

• Is this warping/morphing tech. applicable to all kinds of image transitions?

2D image morphing

What we want :

Page 27: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• Finding out when image morphing tech. is “correct” (between perspective views)?

• How to extend the image morphing method?

Questions (cont.)

Page 28: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

Proposed by S. M. Seitz, C. R. Dyer

Proc. SIGGRAPH’96, pp. 21-30.

VIEW MORPHING

Page 29: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

View Morphing

Morphed View

Virtual Camera

Page 30: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

View Morphing (cont.)

Page 31: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

2D vs. View Morphing

• Distortions occur if only image morphing is applied.

Image morphing

View morphing

Page 32: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• 3D modeling with stereo vision techniques.

• What’re the advantages and disadvantages?

• Image morphing

• Shape-distorting.

• 3D shapes often results in shapes that are mathematically quite different.

• Unless …….

• Is there any special case that image morphing works “correct” for perspective views?

Synthesizing Novel Views

Page 33: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

Synthesizing Novel Views (cont.)

• Image morphing for perspective views.

• Delicately designing the transition of control lines.

• Still requiring an approximate model.

• Parallel views

• Linear image interpolation should produce new perspective views when camera moves parallel to the image plane.

Page 34: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

Parallel Views

• Linear image interpolation should produce new perspective views when camera moves parallel to the image plane.

0100

000

000

0

0

0 f

f

M

Projection Matrix M = [ H | -HC ] P^ = MP

Assume

C0 = (0,0,0) C1 = (CX, CY, 0)

0100

00

00

11

11

1 Y

X

Cff

Cff

M

Page 35: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

Parallel Views (cont.)

PMZ

PMZ

sPMZ

sspps

s

1

11)1()1( 1010

10)1( sMMsM s

p0 I0 , p1 I1 , P = [X Y Z 1]T

p = (1-s) p0 + s p1 = ?

Cs = (sCX, sCY, 0)

fs = (1-s) f0+s f1

Page 36: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

Parallel Views (cont.)

• Interpolating images produced from parallel cameras

• Producing the illusion of simultaneously moving the camera on the line C0C1.

• Moving the optic center and zooming continuously.

• How about non-parallel views?

Page 37: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

Non-Parallel Views

1. Prewarp align views

Page 38: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

Non-Parallel Views

1. Prewarp align views 2. Morph move camera

Page 39: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

Non-Parallel Views

1. Prewarp align views 2. Morph move camera 3. Postwarp point camera

Page 40: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

View Morphing

1. Pre-warp: • Warp the source and

destination image to form parallel views.

2. Morphing: • Interpolating the

prewarped images.

3. Post-warp • Warp the interpolated

image to form the Is

1

1 2

2

3

H0-1

H1-1

Hs

Page 41: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

View Morphing (cont.)

• For simplicity, the pre-warped images are of f = 1.

0100

010

001

ˆ0

0

0 Y

X

C

C

M

0100

010

001

ˆ1

1

1 Y

X

C

C

M

Page 42: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• Prewarping + morphing + postwarping

• Multiple image resampling blurring

• Folds

• Occlusion, visibility.

• Holes

Problems

Page 43: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• Prewarping + morphing + postwarping • Multiple image resampling blurring • Solution1: supersampling. • Solution2: aggregate warp. • ……

• Folds • Occlusion, visibility. • Solution1: Comparing Z values (Z-buffer). • Solution2: Disparity • ……

• Holes • Solution1: interpolating (or extrapolating) neighboring pixels. • Solution2: additional images. • ……

Problems (cont.)

Page 44: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• Besides the interpolated Ms.

• Specifying a continuous transformation of the image plane.

• E.g. interpolating the orientations of image planes.

Producing the Morphing

Page 45: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• Provides • A mobile virtual camera • Better image morphs

• Requires no prior knowledge • No 3D shape information • No dense correspondence • No camera information • No training on other images

• Cons • Limited to interpolation • Problems with occlusions (leads to ghosting) • Prewarp can be unstable (need good F-estimator)

Features of View Morphing

Page 46: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• Visualization • User-controlled virtual camera

• Image postprocessing

• Image databases • Frontal face images for recognition ...

Applications

Page 47: 8. IMAGE AND VIEW MORPHING - CAIG Labcaig.cs.nctu.edu.tw/course/IBMR14/Lecture/IBMR_8Morphing_F14.pdf · 8. IMAGE AND VIEW MORPHING ... 2D image morphing ... •Image morphing •Shape-distorting

• Camera calibration

• E.g. Camera calibration tool box (for OpenCV / Matlab)

• Through point correspondences

• Estimating the fundamental matrix F (or essential matrix E)

• We will introduce in the later lecture notes…

How to estimate H?