Definition
Given two planes and , a homography maps a point on to its corresponding point on : is defined up to scale (8 degrees of freedom). It encodes the full projective relationship between the two planes: straight lines map to straight lines, but parallel lines and distances in general do not.Physical interpretations
- Two images of the same planar surface are related by a homography.
- Two images taken by a camera undergoing pure rotation (no translation) are related by a homography.
- A fronto-parallel rectification maps a tilted planar surface to a canonical view.
Estimating a homography from correspondences
Each point correspondence gives 2 linear equations in the 9 entries of (after eliminating the scale). With 4 or more correspondences the system is: The Direct Linear Transform (DLT) solves for as the right singular vector of corresponding to its smallest singular value (SVD).Normalise input coordinates before running DLT: translate centroid to origin and scale so the mean distance to the origin is . Denormalise afterwards.
RANSAC for robust estimation
In practice, SIFT/ORB feature matching produces many outlier correspondences (mismatches). Applying DLT directly to all matches gives a poor homography. RANSAC solves this:Count inliers
For each remaining correspondence compute the symmetric transfer error:
Count how many pairs satisfy this threshold.
Applications
Image rectification
Given 4 known world points on a planar surface and their image projections, the homography warps the image so the plane appears fronto-parallel — useful for reading text on a tilted book, correcting perspective distortion in a photo of a sign, or “unrolling” a clock face.Panoramic mosaics
When a camera rotates about its optical centre, consecutive frames are related by a homography. SIFT keypoints provide dense correspondences across frames; RANSAC filters mismatches; and the estimated homographies are composed to stitch the frames into a seamless panorama.MATLAB code example
Python resources
Homographies example (Colab)
Interactive notebook: compute and apply homographies using DLT and RANSAC in Python.
E02 — Clock face rectification
Practical exercise: use a homography to rectify a tilted clock face to a frontal view.
Panoramic mosaics with SIFT (Colab)
Build panoramic mosaics by chaining homographies estimated from SIFT feature matches.
Video lecture
Lecture: Homographies and geometric rectification (2021)
Recorded class covering homography estimation, RANSAC, and applications to rectification and mosaics.
Frequently asked questions
How many point correspondences are needed?
How many point correspondences are needed?
A homography has 8 degrees of freedom (9 entries up to scale), so 4 point correspondences are sufficient for an exact solution (if noise-free). For a least-squares estimate over more points, use DLT with all inlier correspondences.
What is the symmetric transfer error?
What is the symmetric transfer error?
The symmetric transfer error measures how well maps points in both directions: it sums the squared distance of from and of from . This is more robust than a one-sided error when both images have noise.
When does a homography NOT exist between two views?
When does a homography NOT exist between two views?
A homography relates two views only when the scene is planar OR the camera translates without any rotation between frames. If the scene is 3D (non-planar) and the camera translates, the correct model is the fundamental matrix (see Multiple View Geometry).
How many RANSAC iterations are needed?
How many RANSAC iterations are needed?
The required number of iterations is , where is the desired success probability (e.g., 0.99), is the outlier fraction, and is the minimal sample size. For 50 % outliers and , about 1177 iterations are needed.
