Affine transformation is a process that uses a matrix to scale, rotate, or translation an image, and is expressed by the following formula.
<Scale>
Setting values for a and e will scale by that number. Below is a 2x example.
<Translation>
Below is the case where only 2 is moved.
<Rotate>
Taking the case of rotation by 90 degrees as an example, the calculation is simple and easy to understand.
<Reflection>
The X value is inverted.
<Shear>
Shear is the application of force in a parallel direction to any surface. This process is also called skew (distortion).
■Example of implementing affine transformation in python
It is also possible to scale and rotate at the same time.
The affine transformation function "Image.NEAREST" defines the data interpolation method when enlarging an image, and uses a method called Nearest Neighbor.
import numpy as np
import tkinter as tk
from PIL import Image, ImageTk
app = tk.Tk()
img = Image.open('test.png') # Get image file information. text.png can be set arbitrarily
<Result>
The left image is the original image, and the right image is the image after affine transformation. (Reference: How to display images using tkinter)