An affine transformation is a linear function with an offset, i.e.
Also called an orthogonal projection.
Also saw this at work at Enlighted.
The matrix form of the affine transformation is as follows:
Unlike the Euclidean Transformation, the affine transformation requires only to be an invertible matrix, not necessarily an orthogonal matrix. After the affine transformation, the cube is no longer square, but the faces are still parallelograms.
Affine transformation combines linear transformations with a translation component. There are
Affine transformation is a linear mapping method that preserves points, straight lines, and planes. Sets of parallel lines remain parallel after an affine transformation. The affine transformation technique is typically used to correct for geometric distortions or deformations that occur with non-ideal camera angles.
import numpy as np from scipy.ndimage import affine_transform # Create a sample image array image = np.zeros((100, 100)) image[50, 50] = 1 # Define the transformation matrix origin = [10, 20] # new origin coordinates scale = [2, 3] # new scale factors matrix = np.array([[scale, 0, origin], [0, scale, origin], [0, 0, 1]]) # Apply the transformation transformed_image = affine_transform(image, matrix) # Display the original and transformed images import matplotlib.pyplot as plt fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4)) ax1.imshow(image) ax1.set_title("Original") ax2.imshow(transformed_image) ax2.set_title("Transformed") plt.show()