16
Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

Embed Size (px)

Citation preview

Page 1: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

Dr. Engr. Sami ur Rahman

Digital Image ProcessingLecture 9: Rotation, Scaling, Shear, Affine Transformation

Page 2: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 2

Courtesy

Gonzalez and Woods

Page 3: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

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

Page 4: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

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

Page 5: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

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

Page 6: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

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

Page 7: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

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ᶲ

Page 8: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

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

Page 9: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

Scaling

University Of Malakand | Department of Computer Science | UoMIPS | Dr. Engr. Sami ur Rahman | 9

Scaling: Resizing an image

Page 10: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

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

Page 11: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

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

Page 12: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

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

Page 13: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

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

Page 14: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

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

Page 15: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

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.

Page 16: Dr. Engr. Sami ur Rahman Digital Image Processing Lecture 9: Rotation, Scaling, Shear, Affine Transformation

Thanks for your attention