# Image Transformation

• Scaling

Zoom in (interpolation) and zoom out.

• Translation

Suppose we want to shift our image in $(t_x, t_y)$ direction. We need to define a matrix $M$ as:

Then we can simply use this equation to get the new position of a certain point $(x,y)$.

• Rotation

Rotation of an image for an angle $\theta$ is achieved by the transformation matrix of the form

• Affine Transformation

In affine transformation, all parallel lines in the original image will still be parallel in the output image. To find the transformation matrix, we need 3 points from input image and their corresponding locations in output image.

• Pespective Transformation

For perspective transformation, you need a $3\times 3$ transformation matrix. Straight lines will remain straight even after the transformation. To find this transformation matrix, you need 4 points on the input image and corresponding points on the output image. Among these 4 points, 3 of them should not be collinear.

NOTE: It does not preserve parallelism, length, and angle. But it still preserves collinearity and incidence.

# Reference

opencv-python-tutorials