2D Image Transforms 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University
Extract features from an image … what do we do next?
Feature matching (object recognition, 3D reconstruction, augmented reality, image stitching) How do you compute the transformation?
Given a set of matched feature points { x i , x 0 i } ← set of point correspondences point in point in the one image other image and a transformation x 0 = f ( x ; p ) transformation parameters function Find the best estimate of p
What kind of transformation functions are there? x 0 = f ( x ; p )
2D Transformations
translation rotation aspect affine perspective cylindrical
2D Planar Transformations
2D Planar Transformations Scale • Each component multiplied by a scalar • Uniform scaling - same scalar for each component
2D Planar Transformations Scale x 0 = ax Scale y 0 = by • Each component multiplied by a scalar • Uniform scaling - same scalar for each component
2D Planar Transformations Scale x 0 a � x � � 0 Scale = y 0 b y 0 scaling matrix S • Each component multiplied by a scalar • Uniform scaling - same scalar for each component
2D Planar Transformations Scaling Shear
2D Planar Transformations Shear x 0 = x + a · y Scaling Shear y 0 = b · x + y
2D Planar Transformations Shear x 0 � x 1 � � a Scaling = Shear y 0 b y 1
2D Planar Transformations x � x = y
2D Planar Transformations x 0 � x 0 = y 0 x � x = y θ
2D Planar Transformations x 0 � Rotation x 0 = y 0 x 0 = x cos θ − y sin θ y 0 = x sin θ + y cos θ x � x = y θ
Polar coordinates… x = r cos ( φ ) y = r sin ( φ ) x’ = r cos ( φ + θ ) (x’, y’) y’ = r sin ( φ + θ ) (x, y) Trig Identity… x’ = r cos( φ ) cos( θ ) – r sin( φ ) sin( θ ) θ y’ = r sin( φ ) cos( θ ) + r cos( φ ) sin( θ ) φ Substitute… x’ = x cos( θ ) - y sin( θ ) y’ = x sin( θ ) + y cos( θ )
2D Planar Transformations x 0 � Rotation x 0 = y 0 cos θ x 0 � x � � − sin θ = y 0 sin θ cos θ y x � x = y θ
2D linear transformation (can be written in matrix form) x 0 = f ( x ; p ) x 0 x � � = M y 0 y parameters point p x
Scale Flip across y s x � − 1 0 � 0 M = M = 0 s y 0 1 Rotate Flip across origin cos θ − 1 � � − sin θ 0 M = M = sin θ cos θ 0 − 1 Shear Identity 1 1 � � s x 0 M = M = 1 s y 0 1
How do you represent translation with a 2 x 2 matrix? x 0 = x + t x y 0 = y + t x y ? � ? M = ? ?
How do you represent translation with a 2 x 2 matrix? x 0 = x + t x y 0 = y + t x not possible
Q: How can we represent translation in matrix form? x 0 = x + t x y 0 = y + t y 25
Homogeneous Coordinates
add a one here 2 3 x � x = ⇒ y 4 5 y 1 inhomogenous coordinates homogenous coordinates Represent 2D point with a 3D vector
Q: How can we represent translation in matrix form? x 0 = x + t x y 0 = y + t y A: append 3rd element and append 3rd column & row 2 3 x 1 0 t x x � M = 0 1 ⇒ t y y 4 5 y 1 0 0 1
Homogeneous Coordinates t x = 2 t y = 1
A 2D point in an image can be represented as a 3D vector x x 1 � ⇐ ⇒ X = x = x 2 y x 3 x = x 1 y = x 2 where x 3 x 3 Why?
Think of a point on the image plane in 3D image plane y P X z X is a projection of a point P on z = 1 x the image plane You can think of a conversion to homogenous coordinates as a conversion of a point to a ray
Conversion: 2 3 x x � • 2D point → homogeneous point ⇒ y 4 5 y 1 append 1 as 3rd coordinate x/w 2 3 x • homogeneous point → 2D point � y 5 ⇒ 4 y/w w divide by 3rd coordinate Special Properties ⇥ x ⇥ x w ⇤ > = λ w ⇤ > • Scale invariant y y ⇥ x 0 ⇤ • Point at infinity y ⇥ 0 • Undefined 0 ⇤ 0
Basic 2D transformations as 3x3 matrices Scale Translate Shear Rotate
Matrix Composition Transformations can be combined by matrix multiplication p ’ = T(t x ,t y ) R( Θ ) S(s x ,s y ) p Does the order of multiplication matter?
2D transformations
Affine Transformation 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 (affine times affine is affine) Will the last coordinate w ever change?
Coming soon… Projective Transform Projective transformations are combos of •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 •Projective matrix is defined up to a scale (8 DOF)
Recommend
More recommend