Upload
duongkhanh
View
242
Download
1
Embed Size (px)
Citation preview
Geometric Transformations,8DOF Transform
Lecture #5Friday January 26, 2018
Classes of Image Transformations• Rigid transformations– Combine rotation and translation– Preserve relative distances and angles– 3 Degrees of freedom
• Similarity transformations– Add scaling to rotation and translation– Preserves relative angles– 4 Degrees of freedom
Affine Transformations• Any transform of the form:!"1=
% & '( ) *0 0 1
,-1
• 6 DOF• Arbitrary combination of– translations– rotations– scales (uniform or non-uniform)– shears
Similarity vs. Affine Matrices• Similarity : 4 DOF
• Affine : 6 DOF
!!!
"
#
$$$
%
&
!!!
"
#
$$$
%
&
=
!!!
"
#
$$$
%
&
11001yx
fedcba
vu
uv1
!
"
###
$
%
&&&=
a b c−b a d0 0 1
!
"
###
$
%
&&&
xy1
!
"
###
$
%
&&&
Specifying Affine Transformations
• There are six unknowns in the matrix (a through f)• If you specify one point in the source image and a
corresponding point in the target image, that yields two equations:
• So providing three point-to-point correspondences specifies an affine matrix
feydxvcbyaxu
iii
iii
++=
++=
Perspective Transformations
• We can go beyond affine transformations.• We can do any perspective transformation of a
one 3D view of a plane to another view.• Therefore, we can model an image as a plane
in space, and project it onto any other image.– How does this differ from the perspective
projection pipeline in CS410?
Perspective Matrix
• Why does element [3,3] = 1?• How many points are needed to specify this matrix?
€
u'v 'w
"
#
$ $ $
%
&
' ' '
=
a b cd e fg h 1
"
#
$ $ $
%
&
' ' '
xy1
"
#
$ $ $
%
&
' ' '
u = u'w , v = v'
w
Solving for Perspective
• Four corresponding points produce eight equations, eight unknowns --- but we can�t observe w
1'
1'
++
++==
++
++==
ii
ii
i
ii
ii
ii
i
ii
hygxfeydx
wvv
hygxcbyax
wuu
Solving (cont.)
• Multiply to get rid of the fraction…
• Now, remember that the u’s, v’s, x’s & y’s are known; group the unknown terms
( )( ) feydxhygxv
cbyaxhygxu
iiiii
iiiii
++=++
++=++
11
iiiiiii
iiiiiii
vhyvgxfeydxvuhyugxcbyaxu
−−++=
−−++=
Solving (III)
• And express the result as a system of linear equations
!!!!!!!!!!!
"
#
$$$$$$$$$$$
%
&
!!!!!!!!!!!
"
#
$$$$$$$$$$$
%
&
−−
−−
−−
−−
−−
−−
−−
−−
=
!!!!!!!!!!!
"
#
$$$$$$$$$$$
%
&
hgfedcba
vyvxyxuyuxyxvyvxyxuyuxyxvyvxyxuyuxyxvyvxyxuyuxyx
vuvuvuvu
444444
444444
333333
333333
222222
222222
111111
111111
4
4
3
3
2
2
1
1
10000001100000011000000110000001
Solving (IV)
• Finally, invert the constant matrix and solve
!!!!!!!!!!!
"
#
$$$$$$$$$$$
%
&
=
!!!!!!!!!!!
"
#
$$$$$$$$$$$
%
&
!!!!!!!!!!!
"
#
$$$$$$$$$$$
%
&
−−
−−
−−
−−
−−
−−
−−
−−−
hgfedcba
vuvuvuvu
vyvxyxuyuxyxvyvxyxuyuxyxvyvxyxuyuxyxvyvxyxuyuxyx
4
4
3
3
2
2
1
11
444444
444444
333333
333333
222222
222222
111111
111111
10000001100000011000000110000001
Solving (V) : Questions
• Is there always a solution?• Under what conditions is the matrix invertible?• Is the solution always unique?
Perspective Image Transforms (Intuition)• What does the following matrix do?
!!!
"
#
$$$
%
& −
100022022
Matrix Decomposition
• Note that such decompositions are:– not unique (why?)– difficult to intuit
!!!!!!
"
#
$$$$$$
%
& −
!!!
"
#
$$$
%
&
=!!!
"
#
$$$
%
& −
100
021
21
021
21
100020002
100022022
original Scale by 2 Rotation
by 45
More Intuitions
• What will the following matrix do?
• More specifically, what will it do to the giraffe image?
1 0 00 1 01 −1 1
"
#
$$$
%
&
'''
Check Your Intuitions
• What�s going on here?
More Intuition Checking
• Part of what you are seeing is a scale effect– positive terms in the bottom row create larger w values, and
therefore smaller u, v values
• Something much weirder is also going on:– What happens when y = x+1?– How do you interpret this geometrically?– Isn’t the perspective transform linear?
• So how do you select transformation matrices?
Perspective Transform of 2D Planes Continued.
• Recall the basic equation for the perspective transform
• The only practical way to specify an image transform is by providing four point correspondences
€
u'v 'w
"
#
$ $ $
%
&
' ' '
=
a b cd e fg h 1
"
#
$ $ $
%
&
' ' '
xy1
"
#
$ $ $
%
&
' ' '
u = u'w , v = v'
w
Computing Transformations
• Remember how to build a transformation from four point correspondences….
!!!!!!!!!!!
"
#
$$$$$$$$$$$
%
&
!!!!!!!!!!!
"
#
$$$$$$$$$$$
%
&
−−
−−
−−
−−
−−
−−
−−
−−
=
!!!!!!!!!!!
"
#
$$$$$$$$$$$
%
&
hgfedcba
vyvxyxuyuxyxvyvxyxuyuxyxvyvxyxuyuxyxvyvxyxuyuxyx
vuvuvuvu
444444
444444
333333
333333
222222
222222
111111
111111
4
4
3
3
2
2
1
1
10000001100000011000000110000001
Computing...• So if we want the following mapping:
(0,0)®(0,0), (0,144)®(0,144), (152,0)®(152,50), (152,144)®(152,94)
!!!!!!!!!!!
"
#
$$$$$$$$$$$
%
&
−−
−−
−
−
−
13536142881144152000218882310400011441520760010152000023104000101522073601144000000000114400010000000000100
…More Computing...
!!!!!!!!!!!
"
#
$$$$$$$$$$$
%
&
=
!!!!!!!!!!!
"
#
$$$$$$$$$$$
%
&
=
!!!!!!!!!!!
"
#
$$$$$$$$$$$
%
&
!!!!!!!!!!!
"
#
$$$$$$$$$$$
%
&
−−
−−
−−−
−−−−
−
−−−−
001497.01077.100274.3
9415250152144000
0000.0000.0000.0000.000.000.000.000.000.000.000.000.000000100007.0007.007.007.007.007.007.002.014.002.007.002.014.002.0000000100000007.0007.022.007.022.014.023.007.023.014.
hgfedcba
M-1u&v
vector
What doesThis say about x?
How doesThis alter it?
Remember the earlierWLOG? c = u1,…
…yields!!!
"
#
$$$
%
&
1001497.01077.100274.3
Back to Attention…
• In PA1, you map attention windows to a target output video size– Using an affine transformation• Why affine? Why not rigid? Why not perspective?