Lecture9 Transformation
Lecture9 Transformation
?
What is the geometric relationship between these
two images?
x x
x x
Richard Szeliski Image Stitching 8
Image Warping
• image filtering: change range of image
• g(x) = h(f(x))
f g
h
p = (x,y) p’ = (x’,y’)
• Computing 2D Transformations
• Linear Least Squares
• Affine
• Perspective (Homography)
Today’s class
• Types of 2D Transformations
• Linear
• Affine
• Perspective (Homography)
• Computing 2D Transformations
• Linear Least Squares
• Affine
• Perspective (Homography)
Common linear transformations
• Rotation by angle θ (about the origin)
θ
(0,0) (0,0)
x = r cos (f)
y = r sin (f)
x’ = r cos (f + q)
y’ = r sin (f + q)
(x’, y’)
(x, y)
q f
2-D Rotation
x = r cos (f)
y = r sin (f)
x’ = r cos (f + q)
y’ = r sin (f + q)
(x’, y’)
Trig Identity…
(x, y) x’ = r cos(f) cos(q) – r sin(f) sin(q)
y’ = r sin(f) cos(q) + r cos(f) sin(q)
q f
2-D Rotation
x = r cos (f)
y = r sin (f)
x’ = r cos (f + q)
y’ = r sin (f + q)
(x’, y’)
Trig Identity…
(x, y) x’ = r cos(f) cos(q) – r sin(f) sin(q)
y’ = r sin(f) cos(q) + r cos(f) sin(q)
q f
Substitute…
x’ = x cos(q) - y sin(q)
y’ = x sin(q) + y cos(q)
2-D Rotation
•This is easy to capture in matrix form:
θ
(0,0) (0,0)
2x2 Matrices
2D Shear?
x ' = x + shx * y é x 'ù é 1 shx ù é x ù
y ' = shy * x + y ê y 'ú = ê sh 1 úû êë y úû
ë û ë y
2x2 Matrices
• Computing 2D Transformations
• Linear Least Squares
• Affine
• Perspective (Homography)
Homogeneous Coordinates
•Homogeneous coordinates
é xù
• represent coordinates in 2
dimensions with a 3-vector
é x ù homogeneous coords ê ú
ê y ú ¾¾ ¾ ¾ ¾¾®ê y ú
ë û êë 1 úû
Homogeneous coordinates (x, y, w)
w
(x/w, y/w, 1)
w=1
x
homogeneous image
coordinates
y
y
2
(2,1,1) or (4,2,2) or (6,3,3)
1
Convenient 1 2 x
coordinate system to
represent many
useful
transformations
Homogeneous Coordinates
é x ' ù é1 0 t x ù é x ù é x 'ù é s x 0 0ù é x ù
ê y ' ú = ê0 1 t ú ê y ú ê y 'ú = ê 0 sy 0úú êê y úú
ê ú ê y úê ú ê ú ê
êë 1 úû êë0 0 1 úû êë 1 úû êë 1 úû êë 0 0 1úû êë 1 úû
Translate Scale
• Computing 2D Transformations
• Linear Least Squares
• Affine
• Perspective (Homography)
Where do we go from here?
Called a homography
(or planar perspective map)
Any two images of the same planar surface in 3D space are
related by a homography (assuming a pinhole camera model).
Homographies
• Homographies …
• Affine transformations, and
• Projective warps
• Computing 2D Transformations
• Linear Least Squares
• Affine
• Perspective (Homography)
Computing transformations
• Given a set of matches between images A and B
• How can we compute the transform T from A to B?
• Computing 2D Transformations
• Linear Least Squares
• Affine
• Perspective (Homography)
Simple case: translations
Displacement of match i =
Mean displacement =
Another view
10
8
(yi, xi)
Mileage
6
4 y = mx + b
0
0 1 2 3 4 5 6
Time
Linear regression
12
10
residual error
Mileage
6
0
0 1 2 3 4 5 6
Time
2n x 2 2x1 2n x 1
Today’s class
• Types of 2D Transformations
• Linear
• Affine
• Perspective (Homography)
• Computing 2D Transformations
• Linear
• Affine
• Perspective (Homography)
Affine transformations
• Cost function:
2n x 6 6x1 2n x 1
Today’s class
• Types of 2D Transformations
• Linear
• Affine
• Perspective (Homography)
• Computing 2D Transformations
• Linear
• Affine
• Perspective (Homography)
Homographies
p’
p
Not linear!
Solving for homographies
Solving for homographies
2n × 9 9 2n
inliers