homography
A homography is the geometric transformation that relates two images of the same flat surface taken from different viewpoints, or, equivalently, two images taken by a camera that only rotates about its centre (with no sideways movement). Intuitively, if you photograph a poster on a wall straight-on and then from an angle, the rectangle becomes a slanted quadrilateral, straight lines stay straight but parallel lines may converge, and the change of one image into the other is captured exactly by a single homography. It is the workhorse mapping behind panorama stitching, perspective correction (deskewing a photographed document), augmented-reality overlays on planar markers, and texture mapping.
Mathematically a homography is a 3-by-3 matrix acting on points written in homogeneous coordinates, which means a 2D point with coordinates (x, y) is represented as a 3-vector (x, y, 1), and any non-zero scalar multiple of that vector denotes the same point. The matrix multiplies this 3-vector to produce another 3-vector, and you recover the transformed 2D point by dividing by its third component (the perspective division). This division is what lets a homography produce the convergence and foreshortening of perspective, which an affine transform cannot. Because the matrix can be scaled by any non-zero constant without changing the mapping, it has 8 degrees of freedom, not 9.
Estimating a homography needs point correspondences: pairs of points known to be the same physical location in both images. Each correspondence gives two equations (one for the x-coordinate, one for the y-coordinate), so four correspondences (eight equations) suffice to solve for the eight unknowns, provided no three of the four points are collinear. The standard method is the Direct Linear Transform (DLT), which arranges the correspondence equations into a homogeneous linear system and solves it via the singular value decomposition. For numerical stability the points are first normalized (translated and scaled to a canonical range), an essential step often skipped by beginners.
In real applications the correspondences come from feature matching and are riddled with outliers, so the homography is estimated inside RANSAC: repeatedly sample four matches, compute a candidate homography, count inlier matches consistent with it, and keep the best, then refine on all inliers. The crucial assumption to remember is planarity: a homography correctly maps a scene only if the imaged surface is flat or the camera motion is a pure rotation. For a general 3D scene with translation, no single homography fits, and parallax appears; that case requires the fundamental or essential matrix and full 3D reconstruction instead.
Deskewing a photographed receipt: click the four paper corners in the photo, map them to the four corners of an upright rectangle, solve the 3×3 homography from these 4 correspondences (DLT), then warp the image by H to get a flat, rectified scan.