Geometric Transformations, Part 2 Lecture #4 Wednesday, January 25, 2017 Programming Assignment #1 • Any questions? 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 ! ! ! " # $ $ $ % & ! ! ! " # $ $ $ % & = ! ! ! " # $ $ $ % & 1 1 0 0 1 y x f e d c b a v u u v 1 ! " # # # $ % & & & = a b c −b a d 0 0 1 ! " # # # $ % & & & x y 1 ! " # # # $ % & & & 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 f ey dx v c by ax u i i i i i i + + = + + =
4
Embed
Geometric Transformations, Part 2 - CS CSU …cs510/yr2017sp/more_progress/L04.pdf · Geometric Transformations, Part 2 Lecture #4 Wednesday, January 25, 2017 Programming Assignment
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Geometric Transformations,
Part 2Lecture #4
Wednesday, January 25, 2017
Programming Assignment #1
• Any questions?
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=
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: