Upload
margaret-shepherd
View
212
Download
0
Embed Size (px)
Citation preview
Dr. Engr. Sami ur Rahman
Digital Image ProcessingLecture 9: Rotation, Scaling, Shear, Affine Transformation
University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 2
Courtesy
Gonzalez and Woods
Transformation
Transformations:Move and rotate objects, scaling, stretching
Euclidean Transformations The Euclidean transformations are the most commonly used transformations. An Euclidean transformation is either a translation, a rotation, or a reflection.The angles and lengths remain constant.
University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 3
Translation
0 1 2 3 4 5
0 0 0 0 0 0 0
1 0 1 4 7 0 0
2 0 1 4 7 0 0
3 0 1 4 8 0 0
4 0 0 0 0 0 0
5 0 0 0 0 0 0
0 1 2 3 4 5
0 0 0 0 0 0 0
1 0 0 0 1 4 7
2 0 0 0 1 4 7
3 0 0 0 1 4 8
4 0 0 0 0 0 0
5 0 0 0 0 0 0
0 1 2 3 4 5
0 0 0 0 0 0 0
1 0 0 0 0 0 0
2 0 0 0 0 0 0
3 0 1 4 7 0 0
4 0 1 4 7 0 0
5 0 1 4 8 0 0
0 1 2 3 4 5
0 0 0 0 0 0 0
1 0 0 0 0 0 0
2 0 0 0 0 0 0
3 0 0 0 1 4 7
4 0 0 0 1 4 7
5 0 0 0 1 4 8
University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 4
Translation
0 1 2 3 4 5
0 0 0 0 0 0 0
1 0 1 4 7 0 0
2 0 1 4 7 0 0
3 0 1 4 8 0 0
4 0 0 0 0 0 0
5 0 0 0 0 0 0
0 1 2 3 4 5
0 0 0 0 0 0 0
1 0 0 0 0 0 0
2 0 0 0 0 0 0
3 0 0 0 1 4 7
4 0 0 0 1 4 7
5 0 0 0 1 4 8
y
x
twy
tvx
University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 5
Translation
1
y
x
100
10
01
y
x
t
t
1
w
v
y
x
twy
tvx
University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 6
Rotation
(x, y)
(x’, y’)
ᶲ
x = r cos (ᶲ)
y = r sin (ᶲ)
x’ = r cos (ᶲ + )y’ = r sin (ᶲ + )Trig Identity…x’ = r cos(ᶲ) cos() – r sin(ᶲ) sin()y’ = r cos(ᶲ) sin() + r sin(ᶲ) cos()
Substitute…x’ = x cos() - y sin()y’ = x sin() + y cos()
r
x = r cos (ᶲ)
y =
r s
in (
ᶲ)
x’ = r cos (ᶲ + )
y’ =
r s
in (
ᶲ +
)
r
University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 7
Sin (ᶲ + ) = sin ᶲ cos + cosᶲ sin
Sin (ᶲ - ) = sin ᶲ cos - cos sinᶲ
cos (ᶲ + ) = cos ᶲ cos - sin sinᶲcos (ᶲ - ) = cos ᶲ cos +sin sinᶲ
Rotation
1
y
x
100
0cossin
0sincos
1
w
v
wvRyx ,,
cossin
sincos
wvy
wvx
University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 8
Scaling
University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 9
Scaling: Resizing an image
Scaling
University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 10
100
00
00
y
x
c
c
1
w
v
wvSyx ,,
wcy
vcx
y
x
1
y
x
Scaling
University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 11
0 1 2 3 4 5 6 7 8 9 10
0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 1 4 7 0 0 0 0 0
2 0 0 0 1 4 7 0 0 0 0 0
3 0 0 0 1 4 8 0 0 0 0 0
4 0 0 0 0 0 0 0 0 0 0 0
5 0 0 0 0 0 0 0 0 0 0 0
6 0 0 0 0 0 0 0 0 0 0 0
7 0 0 0 0 0 0 0 0 0 0 0
8 0 0 0 0 0 0 0 0 0 0 0
9 0 0 0 0 0 0 0 0 0 0 0
0 1 2 3 4 5 6 7 8 9 10
0
1
2
3
4
5
6
7
8
9
Rescaling and interpolation
Interpolation
University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 12
Interpolation: Constructing new data points from existing data points
Types of interpolation Nearest neighbor interpolation Linear interpolation Bilinear interpolation Polynomial interpolation Piecewise constant interpolation Spline interpolation
Shear
University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 13
Shear: the deformation of a material substance in which parallel internal surfaces slide past one another
Horizontal shear Vertical shearNo shear
Shear
University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 14
100
00
001
vs
1
w
v
wy
wsvx v
1
y
x
100
00
01
v
h
s
s
1
w
v
1
y
x
wvsy
vx
h
Horizontal shearVertical shear
Affine Transformation
University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 15
Affine transformation or affine map or an affinity:A transformation which preserves straight lines (i.e., all
points lying on a line initially still lie on a line after transformation)
Preserves ratios of distances between points lying on a straight line (e.g., the midpoint of a line segment remains the midpoint after transformation).
Does not necessarily preserve angles or lengths.
Thanks for your attention