2D Image Transformations
In images, affine transformations map points from one coordinate system to another, changing their position, orientation, or scale while preserving parallelism. To aid with translation, points in heterogenous coordinates are converted to points in homogeneous coordinates , such that given a point in homogeneous coordinates, one returns to heterogeneous by dividing by :
Generally, a 2D affine transformation can be defined as the matrix of the form
such that any general has exactly 6 degrees of freedom.There are numerous affine transformation that can interact with a homogeneous point :
- Scaling is a 2-DoF transformation that enlarges or shrinks objects relative to the origin, such that
Uniform scaling has , whereas non-uniform (anisotropic) scaling changes the aspect ratio of the image.
⠀- Translation (2 DoF) shifts all points by a vector , such that
In homogeneous coordinates, translation becomes a simple matrix multiplication , replacing addition in Cartesian space.
⠀- Rotation (1 DoF) rotates the image counterclockwise by an angle , such that
Chaining two rotations with angles and is the same than applying a rotation with an angle . A rotation matrix is always orthogonal with , and therefore .
⠀- Shearing (2 DoF) distorts shape while keeping lines parallel (i.e., turns a rectangle into a parallelogram), such that
Homogeneous coordinates also allow chaining the four transformations as matrix multiplications. For example, a shearing matrix can be the product of a rotate, then scale non-uniformly (or vice versa). Similarly, a rigid (Euclidean) transform is the product of a rotation and translation transformations (and preserves lengths), whereas a similarity transform adds scaling to the equation (and only preserves angles).