Lecture 8 Warping Morphing 3D Transformation Li Zhang Spring 2010 Most slides borrowed from Yungyu Chuang Last time Forward warping fwarpI I T for y0 yltIheight y ID: 440864
Download Presentation The PPT/PDF document "CS559: Computer Graphics" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
CS559: Computer Graphics
Lecture 8: Warping, Morphing, 3D TransformationLi ZhangSpring 2010
Most slides borrowed from
Yungyu ChuangSlide2
Last time: Forward
warpingfwarp(I, I’, T){
for (y=0; y<I.height; y++)
for (x=0; x<I.width; x++) {
(x’,y’)=T(x,y); I’(x’,y’)=I(x,y); }}
I
I’
x
x’
TSlide3
Last time: Inverse
warpingiwarp(I, I’, T){
for (y=0; y<I’.height; y++)
for (x=0; x<I’.width; x++) {
(x,y)=T-1(x’,y’); I’(x’,y’)=I(x,y);
}}
I
I’
x
x’
T
-1Slide4
Non-parametric image warping
Mappings implied by correspondencesInverse warping
P’
?Slide5
Non-parametric image warpingSlide6
Warping between two triangles
Idea: find an affine that transforms ABC to A’B’C’
A
C
B
A’
C’
B’Slide7
Barycentric coordinates
Idea: represent P using A1,A2,A3Slide8
Non-parametric image warping
P’
Barycentric coordinate
P
Turns out to be equivalent to affine
transform, why? Slide9
Non-parametric image warping
Gaussian
View this problem as a signal reconstruction problem Slide10
Demo
http://www.colonize.com/warp/warp04-2.phpWarping is a useful operation for mosaics, video matching, view interpolation and so on.Slide11
Image morphingSlide12
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.
(1-t) ∙ Image1 + t ∙ Image2Slide13
Image morphing
Why ghosting?Morphing = warping + cross-dissolving
shape
(geometric)
color
(photometric)Slide14
morphing
cross-dissolving
Image morphing
image #1
image #2
warp
warpSlide15
Morphing sequenceSlide16
Image morphing
create a morphing sequence: for each time tCreate an intermediate warping field (by interpolation)
t=0
t=1
t=0.33
A(0)
A(1)
A(0.33)
B(0)
B(1)
B(0.33)
C(0)
C(1)
C(0.33)Slide17
Image morphing
create a morphing sequence: for each time tCreate an intermediate warping field (by interpolation)Warp both images towards it
t=0
t=1
t=0.33
A(0)
A(1)
A(0.33)
B(0)
B(1)
B(0.33)
C(0)
C(1)
C(0.33)Slide18
Image morphing
create a morphing sequence: for each time tCreate an intermediate warping field (by interpolation)Warp both images towards it
t=0
t=1
t=0.33
A(0)
A(1)
A(0.33)
B(0)
B(1)
B(0.33)
C(0)
C(1)
C(0.33)Slide19
Image morphing
create a morphing sequence: for each time tCreate an intermediate warping field (by interpolation)Warp both images towards it
Cross-dissolve the colors in the newly warped images
t=0
t=1
t=0.33
A(0)
A(1)
A(0.33)
B(0)
B(1)
B(0.33)
C(0)
C(1)
C(0.33)Slide20
More complex morph
Triangular MeshSlide21
Results
Michael Jackson’s MTV “Black or White”
http://www.youtube.com/watch?v=YVoJ6OO6lR4
(
5:20 later)Slide22
Multi-source morphingSlide23
Multi-source morphingSlide24
The average face
http://www.uni-regensburg.de/Fakultaeten/phil_Fak_II/Psychologie/Psy_II/beautycheck/english/index.htmSlide25
3D Face morphing
http://www.youtube.com/watch?v=nice6NYb_WABlanz
and Vetter, SIGGRAPH 1998Slide26
Where to now…
We are now done with imagesSlide27
3D Graphics Pipeline
Rendering
(Creating, shading images from geometry, lighting, materials)
Modeling
(Creating 3D Geometry)Slide28
3D Graphics Pipeline
Rendering
(Creating, shading images from geometry, lighting, materials)
Modeling
(Creating 3D Geometry)
Want to place it at correct location in the world
Want to view it from different angles
Want to scale it to make it bigger or smaller
Need transformation between coordinate systems -- Represent transformations using matrices and matrix-vector multiplications. Slide29
Next …
We will spend several weeks on the mechanics of 3D graphics3D TransformCoordinate systems and ViewingDrawing lines and polygonsLighting and shadingMore advanced: mathematical representation of lines and surfaces, texture mapping, animationSlide30
Recall: All 2D Linear Transformations
Linear transformations are combinations of …
Scale,
Rotation,
Shear, andMirrorSlide31
2D Rotation
Rotate counter-clockwise about the origin by an angle
x
y
x
y
Slide32
Rotating About An Arbitrary Point
What happens when you apply a rotation transformation to an object that is not at the origin?
x
y
?Slide33
Rotating About An Arbitrary Point
What happens when you apply a rotation transformation to an object that is not at the origin?It translates as well
x
y
xSlide34
How Do We Fix it?
How do we rotate an about an arbitrary point?Hint: we know how to rotate about the origin of a coordinate systemSlide35
Rotating About An Arbitrary Point
x
y
x
y
x
y
x
ySlide36
Back to Rotation About a Pt
Say R is the rotation matrix to apply, and p is the point about which to rotateTranslation to Origin:Rotation:Translate back:How to express all the transformation using matrix multiplication? Slide37
Scaling an Object not at the Origin
What happens if you apply the scaling transformation to an object not at the origin?Slide38
Composing rotations, scales
Rotation and scaling are not commutative.Slide39
Inverting Composite Transforms
Say I want to invert a combination of 3 transformsOption 1: Find composite matrix, invertOption 2: Invert each transform and swap orderSlide40
Inverting Composite Transforms
Say I want to invert a combination of 3 transformsOption 1: Find composite matrix, invertOption 2: Invert each transform and swap orderObvious from properties of matricesSlide41
Homogeneous Transform Advantages
Unified view of transformation as matrix multiplicationEasier in hardware and softwareTo compose transformations, simply multiply matricesOrder matters: BA vs ABAllows for transforming directional vectorsAllows for non-affine transformations when last row is not (0,0,1)Slide42
Directions vs. Points
We have been talking about transforming pointsDirections are also important in graphicsViewing directionsNormal vectorsRay directionsDirections are represented by vectors, like points, and can be transformed, but not like points
(1,1)
(-2,-1)
x
ySlide43
Transforming Directions
Say I define a direction as the difference of two points: d=a–bThis represents the direction of the line between two pointsNow I transform the points by the same amount: a’
=M*
a
+t, b’=M*b+td’=a’–b’=M*(a-b
)=M*dTranslation does not matterSlide44
Homogeneous Directions
Translation does not affect directions!Homogeneous coordinates give us a very clean way of handling thisThe direction (x,y) becomes the homogeneous direction (x,y,0)
M can be any linear transformation: rotation, scaling, etcSlide45
Homogeneous Directions
Translation does not affect directions!Homogeneous coordinates give us a very clean way of handling thisThe direction (x,y) becomes the homogeneous direction (x,y,0)
M can be any linear transformation: rotation, scaling, etc
Uniform scaling
changes the length of the vector, but not the directionHow to represent this equivalence Slide46
Homogeneous
CoordinatesIn general, homogeneous coordinates (x, y, w)
How to interpret
the case for
w
= 0?
Point at infinity
: directional vector
(1,2,1)
(2,4,2)
(2,3,0) (6,9,0)Slide47
Transforming Normal Vector
Why
normal vectors are special?Slide48
Transforming normal vectors
tangent
normal
tangent’
normal’
M
If M is a rotation,