Image Warping http://www.jeffre-martin.com Some slides from Steve Seitz 5-463: Computational Photograph Aleei Efros, CMU, Fall 2
Image Transformations image filtering: change range of image g() T(f()) f T f image warping: change domain of image f g() f(t()) T f
Image Transformations image filtering: change range of image g() T(f()) f T g image warping: change domain of image f g() f(t()) T g
Parametric (global) warping Eamples of parametric warps: translation rotation aspect affine perspective clindrical
Parametric (global) warping T p (,) p (, ) Transformation T is a coordinate-changing machine: p T(p) What does it mean that T is global? Is the same for an point p can be described b just a few numbers (parameters) Let s represent T as a matri: p Mp M
Scaling Scaling a coordinate means multipling each of its components b a scalar Uniform scaling means this scalar is the same for all components: 2
Scaling Non-uniform scaling: different scalars per component: X 2, Y.5
Scaling Scaling operation: Or, in matri form: b a b a scaling matri S What s inverse of S?
2-D Rotation (, ) (, ) θ cos(θ) - sin(θ) sin(θ) + cos(θ)
2-D Rotation θ φ (, ) (, ) r cos (φ) r sin (φ) r cos (φ + θ) r sin (φ + θ) Trig Identit r cos(φ) cos(θ) r sin(φ) sin(θ) r sin(φ) cos(θ) + r cos(φ) sin(θ) Substitute cos(θ) - sin(θ) sin(θ) + cos(θ)
2-D Rotation This is eas to capture in matri form: cos sin θ Even though sin(θ) and cos(θ) are nonlinear functions of θ, is a linear combination of and is a linear combination of and What is the inverse transformation? Rotation b θ For rotation matrices ( θ ) sin( θ ) ( ) ( ) R cos T R R θ
22 Matrices What tpes of transformations can be represented with a 22 matri? 2D Identit? 2D Scale around (,)? s s * * s s
22 Matrices What tpes of transformations can be represented with a 22 matri? 2D Rotate around (,)? * cos * sin * sin * cos + cos sin sin cos 2D Shear? sh sh + + * * sh sh
22 Matrices What tpes of transformations can be represented with a 22 matri? 2D Mirror about Y ais? 2D Mirror over (,)?
22 Matrices What tpes of transformations can be represented with a 22 matri? 2D Translation? + t + t NO! Onl linear 2D transformations can be represented with a 22 matri
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 a c b d a c be d g fi h k j l
Consider a different Basis j (,) v (v,v ) q p u(u,u ) i (,) q4i+3j (4,3) p4u+3v
Linear Transformations as Change of Basis v (v,v ) j (,) p uv p ij p uv (4,3) p 4u +3v p 4u +3v u(u,u ) p ij 4u+3v An linear transformation is a basis!!! i (,) u p ij v4 u v p uv u v3 u v
What s the inverse transform? j (,) v (v,v ) p ij p uv u(u,u ) p ij (5,4) p uv i (,) p u + p v u u v v - 5 4 u u v v p uv (p,p )? - p ij How can we change from an basis to an basis? What if the basis are orthogonal?
Projection onto orthogonal basis j (,) v (v,v ) p ij p uv p ij (5,4) i (,) p uv (u p ij, v p ij ) u(u,u ) p uv u v u v 5 4 u v u v p ij
Homogeneous Coordinates Q: How can we represent translation as a 33 matri? + t + t
Homogeneous Coordinates Homogeneous coordinates represent coordinates in 2 dimensions with a 3-vector homogeneou scoords
Homogeneous Coordinates Add a 3rd coordinate to ever 2D point (,, w) represents a point at location (/w, /w) (,, ) represents a point at infinit (,, ) is not allowed 2 (2,,) or (4,2,2) or (6,3,3) Convenient coordinate sstem to represent man useful transformations 2
Homogeneous Coordinates Q: How can we represent translation as a 33 matri? A: Using the rightmost column: t t Translation t t + +
Translation Eample of translation + + t t t t t 2 t Homogeneous Coordinates
Basic 2D Transformations Basic 2D transformations as 33 matrices cos sin sin cos t t sh sh Translate Rotate Shear s s Scale
Matri Composition Transformations can be combined b matri multiplication w s s t t w cos sin sin cos p T(t,t ) R() S(s,s ) p
Affine Transformations Affine transformations are combinations of Linear transformations, and Translations Properties of affine transformations: Origin does not necessaril map to origin Lines map to lines Parallel lines remain parallel Ratios are preserved Closed under composition Models change of basis w a d b e c f w Will the last coordinate w alwas be?
Projective Transformations Projective transformations Affine transformations, and Projective warps Properties of projective transformations: w Origin does not necessaril map to origin Lines map to lines Parallel lines do not necessaril remain parallel Ratios are not preserved Closed under composition Models change of basis a d g b e h c f i w
2D image transformations These transformations are a nested set of groups Closed under composition and inverse is a member