Parametric transformations
A transformation is a machine that changes coordinates: every point goes to . It is global (or parametric) when the same rule applies to every point and a few parameters describe it: 2 for a translation, 1 for a rotation, 2 for a scaling. Aligning two images, for example from matched features, means finding these parameters. The plane here uses image coordinates, with to the right and down; the image covers with its center at the origin. The faint grid and "F" are the original, the solid ones their image under the transformation. The two colored segments start out parallel; on the teal one, the dot is the image of its midpoint and the ring is the midpoint of its image.
Linear transformations
Scaling, rotation, mirroring and shear are linear: a 2 × 2 matrix times the point.
Because points down, a positive angle turns clockwise on the screen. Mirroring over the origin, , , is the same as a rotation by 180°. Every combination of these maps is linear again, and linear maps share a set of properties:
- the origin maps to the origin,
- lines map to lines,
- parallel lines remain parallel,
- ratios along a line are preserved, e.g. the midpoint stays the midpoint,
- they are closed under composition.
The determinant tells how areas change: a rotation has , a scaling , a shear . A negative determinant means the plane is flipped over, as by the mirror at the -axis: the "F" then reads backwards.
Translation and homogeneous coordinates
A translation , is not linear: it moves the origin, and no 2 × 2 matrix can do that. Homogeneous coordinates solve this with a third coordinate 1, which turns the translation into a matrix product as well:
All other maps get the 2 × 2 matrix in the top left corner of a 3 × 3 matrix, and a sequence of transformations becomes a single product. The order matters: in the rightmost factor acts first. Here the point is mirrored and scaled first, then sheared, rotated about the origin and finally translated.
Affine transformations
Linear maps followed by a translation are affine, with six free entries:
They keep all the properties of linear maps except that the origin may move: lines stay lines, parallel lines stay parallel and ratios along a line are preserved.
Projective transformations
A projective transformation, or homography, combines an affine map with a perspective part that fills the last row:
Now is no longer 1, and the point is . Points with a larger are pulled towards the origin, so the image looks like a plane seen at an angle. Multiplying the whole matrix by a factor multiplies , and alike and gives the same points, so is only defined up to scale: 9 entries, but 8 degrees of freedom.
- Lines still map to lines, and projective maps are closed under composition.
- Parallel lines do not necessarily remain parallel. All lines with direction contain the point at infinity , so their images meet at . Its is 0 for affine maps, but otherwise it is a finite point: the vanishing point of that direction.
- Ratios are not preserved: the image of the midpoint is no longer the midpoint of the image segment.
A photo of a flat object, such as a document or a facade, is related to its front view by such a transformation. Knowing , the photo can be unwarped (rectified) into the front view.
Try this
- Choose the identity, then set and , and pick the point . rotates it to and then moves it to . In the order it would be moved to first and land at : the order of composition matters.
- Choose the mirror at the -axis: the "F" reads backwards and turns negative. The mirror over the origin only turns the "F" upside down without flipping it, because it is a rotation by 180°.
- Set only : the square becomes a parallelogram, but , so its area is unchanged. Add and the determinant becomes .
- Starting from the identity, set only : the vertical grid lines stay parallel, since their direction gives , while the horizontal ones now point at , i.e. on the -axis. Then try only .
- In the projective preset, compare the dot (image of the midpoint) and the ring (midpoint of the image segment) on the teal line: they separate, so ratios are not preserved.
- Pick a point and follow the panel: turns into , and only the division by gives the point. Scaling all of would scale together and change nothing.