image morphing

35
Image Morphing Michael Kazhdan (601.457/657) HB Ch. 16.5 Feature Based Image Metamorphosis, Beier and Neely 1992

Upload: others

Post on 23-Apr-2022

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Image Morphing

Image Morphing

Michael Kazhdan

(601.457/657)

HB Ch. 16.5

Feature Based Image Metamorphosis, Beier and Neely 1992

Page 2: Image Morphing

Image Morphingβ€’ Animate transition between two images

H&B Figure 16.9

Page 3: Image Morphing

Image Morphingβ€’ Animate transition between two images

H&B Figure 16.9

Two Components:

β€’ Blending

β€’ Warping

Page 4: Image Morphing

BlendingCombine images using an 𝛼𝛼-blend (𝛼𝛼 ∈ 0,1 ):

blend 𝑖𝑖, 𝑗𝑗,𝛼𝛼 = 1 βˆ’ 𝛼𝛼 β‹… Img1 𝑖𝑖, 𝑗𝑗 + 𝛼𝛼 β‹… Img2(𝑖𝑖, 𝑗𝑗)

𝛼𝛼 = 0.0 𝛼𝛼 = 1.0𝛼𝛼 = 0.5

Img1 Img2blend

𝛼𝛼

Page 5: Image Morphing

Image WarpingDeform Img1 so its shape matches that of Img2…

Img1

Img2

𝛼𝛼 = 0.0 𝛼𝛼 = 1.0𝛼𝛼 = 0.5 𝛼𝛼

Page 6: Image Morphing

Image WarpingDeform Img1 so its shape matches that of Img2…

warpwarp

𝛼𝛼 = 0.0 𝛼𝛼 = 1.0𝛼𝛼 = 0.5 𝛼𝛼

Img1

Img2

Page 7: Image Morphing

Image WarpingDeform Img2 so its shape matches that of Img1…

warp warp

warpwarp

𝛼𝛼 = 0.0 𝛼𝛼 = 1.0𝛼𝛼 = 0.5 𝛼𝛼

Img1

Img2

Page 8: Image Morphing

Image Morphing… then blend

warp warp

warpwarp

blend

𝛼𝛼 = 0.0 𝛼𝛼 = 1.0𝛼𝛼 = 0.5 𝛼𝛼

Img1

Img2

Page 9: Image Morphing

Image Morphingβ€’ The warping step is the hard one

Aim to align features in images

H&B Figure 16.9

How do we specifythe mapping for the warp?

Page 10: Image Morphing

Feature-Based Warpingβ€’ [Beier & Neeley, 1992] use a pair of lines to specify

the warp Given 𝑝𝑝 in destination image, where is 𝑝𝑝𝑝 in the source? Describe 𝑝𝑝 relative to the destination line Map the description to the source

Source image Destination image

𝑝𝑝

𝑒𝑒

𝑣𝑣

𝑒𝑒 is a signed fraction𝑣𝑣 is a signed length (in pixels)

Beier & NeeleySIGGRAPH 92

𝑒𝑒 𝑣𝑣

𝑝𝑝𝑝

Page 11: Image Morphing

Feature-Based WarpingHow do we calculate 𝑒𝑒 and 𝑣𝑣?

Recall:𝑣𝑣1, 𝑣𝑣2 = π‘₯π‘₯1 β‹… π‘₯π‘₯2 + 𝑦𝑦1 β‹… 𝑦𝑦2

= 𝑣𝑣1 β‹… 𝑣𝑣2 β‹… cosπœƒπœƒ

The (signed) length of theprojection of 𝑣𝑣1 on the linethrough 𝑣𝑣2, scaled by thelength of 𝑣𝑣2.

β‡’ The signed length of the projectionof 𝑣𝑣1 onto the line through 𝑣𝑣2 is:

𝑣𝑣1, 𝑣𝑣2𝑣𝑣2

𝑣𝑣1 = (π‘₯π‘₯1,𝑦𝑦1)

𝑣𝑣2 = π‘₯π‘₯2,𝑦𝑦2

πœƒπœƒ

Page 12: Image Morphing

How do we calculate 𝑒𝑒 and 𝑣𝑣?

𝑣𝑣1, 𝑣𝑣2 is the (signed) length of the projection of 𝑣𝑣1on the line through 𝑣𝑣2, scaled by the length of 𝑣𝑣2.

𝑣𝑣 =𝑝𝑝 βˆ’ 𝑠𝑠, 𝑑𝑑 βˆ’ 𝑠𝑠 βŠ₯

𝑑𝑑 βˆ’ 𝑠𝑠 βŠ₯

Feature-Based Warping

𝑣𝑣1 𝑣𝑣2

𝑝𝑝

𝑣𝑣𝑑𝑑

𝑠𝑠𝑣𝑣

Page 13: Image Morphing

How do we calculate 𝑒𝑒 and 𝑣𝑣?

𝑣𝑣1, 𝑣𝑣2 is the (signed) length of the projection of 𝑣𝑣1on the line through 𝑣𝑣2, scaled by the length of 𝑣𝑣2.

𝑒𝑒 =𝑝𝑝 βˆ’ 𝑠𝑠, 𝑑𝑑 βˆ’ 𝑠𝑠

𝑑𝑑 βˆ’ 𝑠𝑠⋅

1𝑑𝑑 βˆ’ 𝑠𝑠

Feature-Based Warping

𝑣𝑣1 𝑣𝑣2

Remember: 𝑒𝑒 is a fraction

𝑝𝑝

𝑒𝑒

𝑑𝑑

𝑠𝑠

Page 14: Image Morphing

Feature-Based Warpingβ€’ [Beier & Neeley, 1992] use a pair of lines to specify

the warp Given 𝑝𝑝 in destination image, where is 𝑝𝑝𝑝 in the source? Describe 𝑝𝑝 relative to the destination line Map the description to the source

Beier & NeeleySIGGRAPH 92

Source image Destination image

𝑝𝑝

𝑒𝑒

𝑣𝑣

𝑒𝑒 is a signed fraction𝑣𝑣 is a signed length (in pixels)

𝑒𝑒 𝑣𝑣

𝑝𝑝𝑝

Page 15: Image Morphing

Warping with One Line Pairβ€’ What happens to the β€œF”?

Translation!

Page 16: Image Morphing

Warping with One Line Pairβ€’ What happens to the β€œF”?

Non-uniform scale!

Page 17: Image Morphing

Warping with One Line Pairβ€’ What happens to the β€œF”?

Rotation!

Page 18: Image Morphing

Warping with One Line Pairβ€’ What happens to the β€œF”?

What types of affine transformations can’t be specified?

Page 19: Image Morphing

Warping with One Line Pairβ€’ Can’t specify arbitrary scales, skews, mirrors,

angular changes…

X

Page 20: Image Morphing

Warping with Multiple Line Pairsβ€’ Use weighted combination of points defined by

each pair of corresponding lines

Beier & Neeley, Figure 4

Page 21: Image Morphing

Warping with Multiple Line Pairsβ€’ Use weighted combination of points defined by

each pair of corresponding lines

Source image Destination image

𝑝𝑝Mapping

𝑝𝑝2𝑝𝐿𝐿1𝑝 𝐿𝐿2𝑝 𝐿𝐿1

𝐿𝐿2

𝑝𝑝1𝑝

Page 22: Image Morphing

Warping with Multiple Line Pairsβ€’ Use weighted combination of points defined by

each pair of corresponding lines

Source image Destination image

𝑝𝑝Mapping

𝑝𝑝𝑝

𝑝𝑝𝑝 is a weighted average

𝐿𝐿1𝑝 𝐿𝐿2𝑝 𝐿𝐿1𝐿𝐿2

Page 23: Image Morphing

Weighting Effect of Each Line Pairβ€’ Given a set of line pairs {𝐿𝐿𝑖𝑖𝑖𝑖 0 , … , 𝐿𝐿𝑖𝑖𝑖𝑖 𝑁𝑁 } and

{πΏπΏπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œ 0 , … , πΏπΏπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œ 𝑁𝑁 }, to weight the contribution of each line pair, [Beier & Neeley, 1992] use:

weight 𝑖𝑖 𝑝𝑝 ~length 𝑖𝑖 𝑐𝑐

π‘Žπ‘Ž + dist 𝑖𝑖 𝑝𝑝

𝑏𝑏

where:β€’ length[𝑖𝑖] is the length of line πΏπΏπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œ[𝑖𝑖]β€’ dist[𝑖𝑖](𝑝𝑝) is the distance from 𝑝𝑝 to πΏπΏπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œ[𝑖𝑖]β€’ π‘Žπ‘Ž (small), 𝑏𝑏 ∈ [0.5,2.0], 𝑐𝑐 ∈ [0.0,1.0] are

constants that control the warp

Page 24: Image Morphing

How do we calculate dist?

dist 𝑝𝑝 = �𝑣𝑣 if 𝑒𝑒 ∈ [0,1]𝑝𝑝 βˆ’ 𝑠𝑠 if 𝑒𝑒 < 0𝑝𝑝 βˆ’ 𝑑𝑑 if 𝑒𝑒 > 1

Feature-Based Warping

𝑝𝑝

𝑒𝑒

𝑣𝑣𝑑𝑑

𝑠𝑠

Page 25: Image Morphing

Given a source image and set of corresponding line segment pairs:

β€’ Iterate over each pixel in the target For each pair of line segments

Β» Compute the corresponding position in the sourceΒ» Compute the weights

Average to get the final source position Sample the source (at the source position) to get the

color at the target pixel

Warping

Page 26: Image Morphing

Warping PseudocodeWarp( Imgin , Lin[…] , Lout[…] ){

foreach destination pixel pout:pin = (0,0)sum = 0for i = 1 to number of line pairs:

qin = pout transformed by ( Lin[i] , Lout[i] )pin += qin * weight[i]( pout ) sum += weight[i]( pout )

pin /= sumImgout(pout) = Imgin( pin )

return Imgout}

Page 27: Image Morphing

Given two images, given a set of corresponding line segment pairs, and an interpolation time 𝛼𝛼 ∈ [0,1]:

β€’ Compute the 𝛼𝛼-blend of the of line segments (by blending the end-points)

β€’ Warp the first image using the first set of line segments and the blended line segments

β€’ Warp the second image using the second set of line segments and the blended line segments

β€’ Compute the 𝛼𝛼-blend of the warped images

Morphing at 𝜢𝜢 ∈ [𝟎𝟎,𝟏𝟏]

Page 28: Image Morphing

Morphing at 𝜢𝜢 ∈ [𝟎𝟎,𝟏𝟏] PseudocodeMorph( Img0 , L0[N] , Img1 , L1[N] , 𝛼𝛼 ){

foreach i ∈ {1,…,N}:L[i] = line 𝛼𝛼-th of the way from L0[i] to L1[i]

Warp0 = Warp( Img0 , L0[] , L[] )Warp1 = Warp( Img1 , L1[] , L[] )

return (1-𝛼𝛼)*Warp0 + 𝛼𝛼*Warp1}

warp

𝛼𝛼-blend

Page 29: Image Morphing

Animation PseudocodeAnimate( Img0 , L0[N] , Img1 , L1[N], Imgsout[T+1] ){

foreach t∈{0,…,T}:Imgsout[t] = Morph(Img0 , L0[N] , Img1 , L1[N] , t/T )

}

Page 30: Image Morphing

MorphingCheck out Michael Jackson’s β€œBlack or White” video at:

https://www.youtube.com/watch?v=pTFE8cirkdQ

Page 31: Image Morphing

[Beier & Neeley, 1992] Example

Image0

Image1

Warp0

Warp1

Result

Page 32: Image Morphing

[Beier & Neeley, 1992] Example

Img0

Img1

Warp0

Warp1

Result

Page 33: Image Morphing

[Beier & Neeley, 1992] Example

Warp0

Warp1

Result

Img0

Img1

Page 34: Image Morphing

Extensions:

β€’ Apply to consecutive frames in a video to generate in-between frames (for slow-motion).

β€’ Automate the calculation of correspondences.

Limitations:

β€’ Occlusions

[Beier & Neeley, 1992] Example

Page 35: Image Morphing

Image Processing

β€’ Quantization Uniform quantization Random dither Ordered dither Floyd-Steinberg dither

β€’ Pixel operations Add random noise Compute luminance Change contrast Change saturation

β€’ Filtering Blur Detect edges

β€’ Sampling Nyquist rate Aliasing Ideal filter

β€’ Morping Blending Warp