Professional Documents
Culture Documents
Basic 2D Transformations
Scaled Rotated
Original
Rotated Scaled
Original
Affine Transformation
Consider any matrix of the form:
a1 a2 a3
a a5 a6
4
0 0 1
j j
1 0 0 1 1 (x , y
j j
n
E (a1 , a2 , a3 , a4 , a5 , a6 ) = ∑ ( x*j − x j ) 2 + ( y *j − y j ) 2
j =1
n
(
E (a) = ∑ (a1 x' j + a2 y ' j + a3 − x j ) 2 + (a4 x' j + a5 y ' j + a6 − y j ) 2
j =1
)
∑ x 2j ∑x y ∑x j j j 0 0 0 ∑ x j x 'j
j j j j
x y 0 a1 ∑ y j x 'j
∑ ∑y ∑y 2
0 0
j
j j
j
j
j
j
j
a2 '
∑ xj ∑ y ∑1 j 0 0 0
a3 ∑
xj
j j j
= j
0 0 0 ∑x ∑x y 2
j j j ∑j x j a4 ∑j x j y 'j
j j a
0 0 0 ∑x y ∑y j j
2
j ∑j y j a5 ∑j y j y 'j
j j 6
0
0 0 ∑x ∑y j j ∑j
1 ∑ j
j
y '
j j
Least Squares Error Solution
Ax = B
The solution is:
X = A-1B
a1
a
2
x y 1 0 0 0 a3 x'
0 0 0 x y 1 a = y '
4
a5
a6
Recovering Best Affine
Transformation
Given three pairs of corresponding
points, we get 6 equations
x1 y1 1 0 0 0 a1 x1 '
0 0 0 x1 y1 1 a2 y1 '
x2 y2 1 0 0 0 a3 x2 '
=
0 0 0 x2 y2 1 a4 y2 '
x3 y3 1 0 0 0 a5 x3 '
0 0 0 x3 y3 1 a6 y3 '
Ax=B x=A-1B
Pseudo inverse
For an over-constrained linear system
Ax = B
A has more rows than columns
Multiply by AT on both sides
ATAx = ATB
ATA is a square matrix of as many rows as x
We can take its inverse
x = (ATA)-1ATB
2D Displacement Models
x' = x + b1
Translation:
y ' = y + b2
x' = x cosθ − y sin θ + b1
Rigid:
y ' = x sin θ + y cosθ + b2
x' = a1 x + a2 y + b1 Difference b/w
Affine: affine and rigid?
y ' = a3 x + a4 y + b2
Affine does not
a x + a2 y + b1 have the
Projective: x' = 1 orthonormality
c1 x + c2 y + 1 constraint
a3 x + a4 y + b2
y' =
c1 x + c2 y + 1
Stratification
h11 h12 h13 Concurrency, collinearity,
Projective h order of contact (intersection,
8dof 21 h22 h23 tangency, inflection, etc.),
h31 h32 h33 cross ratio
2D Affine Warping
Warping
Inputs:
Image X
Affine Transformation A = [a1 a2 b1 a3 a4 b2]T
Output:
Generate X’ such that X’ = AX
Obvious Process:
For each pixel in X
Apply transformation
At that location in X’, put the same color as at the original
location in X
Problems?
Warping
This will leave holes…
Because every pixel does not map to an integer
location!
Reverse Transformation
For each integer location in X’
Apply inverse mapping
Problem?
Will not result in answers at integer locations,
in general
Bilinearly interpolate from 4 neighbors
Interpolation…
In 1D 3
4 5
4.3 ?
Use y=mx+c
m = 1, c = -2
Substitute x=4.3, => y = 2.3
2D Bilinear Interpolation
Four nearest points (x, y ) (x, y )
of (x, y)
εx
(x, y ) (x, y )