Tuesday, 2 January 2024

Affine transformations in OpenCV

 

Affine transformations transform the image by maintaining parallelism and ratio of distances. These are used in image processing to perform operations such as translation, rotation, scaling, and shearing.

 

Characteristics of Affine transformations

a.   Preserve parallelism: If two lines are parallel, then they will be parallel after transformation also. If three points colinear before transformation, they are colinear after transformation also.

b.   Preserve ratios: It preserve the ratios of distances between points along a straight line.

 

Following are the basic affine transformations in Image processing.

 

a. Translation: Move an object or image by a fixed distance along the x and y axes. Transformation matrix for this operation is defined like below.

 

[1 0 tx]

[0 1 ty]

 

Here, (tx, ty) represent the translation distances in the x and y directions.

 

b. Rotation: Rotate an object or image by a fixed angle. The transformation matrix for 2D rotation is given below.

 

[cos(θ) -sin(θ)]

[sin(θ) cos(θ)]

 

Θ represents the angle of rotation.

 

c. Scaling: It change the size of an object or image. The transformation matrix for 2D rotation is given below.

 

[sx 0]

[0 sy]

 

Here, (sx, sy) represent the scaling factors along the x and y directions. Scaling factors > 1 increase the size, <1 decrease the size.

 

d. Shearing: Shearing distorts an object or image by skewing it in one direction while leaving the other direction unchanged. There are different types of shearing operations like horizontal shearing, vertical shearing.

Previous                                                    Next                                                    Home

No comments:

Post a Comment