- Scaling

Zoom in (interpolation) and zoom out.

1 | cv2.resize() |

- 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)$.

1 | cv2.warpAffine() |

- Rotation

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

1 | cv2.getRotationMatrix2D() |

- 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**.

1 | cv2.getAffineTransform() |

- 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.

1 | cv2.getPerspectiveTransform() |