Problemcore
Homography estimation
Also called planar homography fitting.
Find the homography that best maps one set of image points to another, from at least four point pairs in general position.
Homography estimation is the problem of finding the homography that maps a set of points of one image to their matches in another image, with . Four pairs with no three points on a line fix exactly; with more pairs and noise, the answer depends on the cost that is minimized. This page states the problem, its costs and its methods. The DLT for homographies is the linear method, Hartley normalization is the step that makes it accurate, and algebraic and geometric error compares the costs.
In plain words
You have two photos of a flat poster, taken from different places, and you have marked the same corners and spots in both. You want the one rule that moves every point of the first photo to its place in the second. A rule of this kind has eight free numbers, and each marked pair gives two equations, so four pairs are enough if no three of the spots are on one line. Real marks are a little wrong, so you use more pairs and look for the rule that fits them best. Some marks can be plain wrong; then you also need a way to find and ignore them.
Definition
Input. Pairs of image points , , with , in homogeneous coordinates or in pixels.
Output. An invertible matrix , up to a nonzero factor, that minimizes a chosen cost. The usual costs, from the cheapest to the most meaningful:
- Algebraic error. with , where is as a 9-vector and is the matrix of the DLT. Each row is linear in .
- Transfer error. , with the image distance. This is the maximum likelihood cost when only the second image has noise.
- Symmetric transfer error. .
- Reprojection error. Minimize over and corrected points the sum . Under independent isotropic Gaussian noise in both images this is the maximum likelihood estimate (HZ Section 4.3); Hartley and Zisserman call the method that minimizes it the Gold Standard algorithm. See reprojection error.
- Sampson error. A first-order approximation of the reprojection error that needs no corrected points (see Sampson distance).
Number of solutions. If the data are exact and come from an invertible :
- with no three of the on a line: exactly one . Then no three of the are on a line either.
- with four of the points in that general position: exactly one , and every cost above is 0 at it.
- Three of four points on a line, or all points on a line: infinitely many solutions, and the DLT matrix loses rank.
With noise and no fits exactly, and the costs have different minimizers.
Variants
- With outliers. Some pairs are wrong matches. Fit a homography to random minimal samples of 4 pairs and keep the one with the largest consensus, as in RANSAC, then refit on the inliers. This is the usual setting with automatic feature matching (HZ Section 4.8).
- From lines. Lines map as , so matched lines give the same kind of linear equations for . Points and lines can be mixed.
- Fewer degrees of freedom. If the camera only turns and is known, has 3 degrees of freedom, and two pairs fix it. An affine model has 6 and needs three pairs. Fit the smaller model when it is true: it needs fewer pairs and is less sensitive to noise (see the hierarchy of planar transformations).
- From pixel values. Instead of points, minimize the difference of the image intensities after warping by . This is direct image alignment, for example by inverse compositional alignment.
Examples
- Exact, four pairs. The unit square , , , and the trapezoid , , , give the unique answer , as the DLT page works out.
- Degenerate, three collinear points. Map , , , to themselves. The identity fits, but so does for every : on the line the third row gives , so the three collinear points stay fixed, and . So the four pairs do not fix , and the DLT matrix has a null space of dimension 2.
- Different costs, different answers. With noise, the algebraic error weights each pair by a factor that depends on its position and on the coordinate frame, while the transfer and reprojection errors count pixels. So the DLT on raw pixel coordinates and the Gold Standard method return different ; Hartley normalization brings the DLT answer close to the Gold Standard one in practice.
Known algorithms
- Normalized DLT (HZ Algorithm 4.2): normalize each image, solve in the least squares sense by the SVD, and undo the normalization. Linear, with no iterations. See DLT for homographies.
- Gold Standard method (HZ Section 4.5): start from the normalized DLT and minimize the reprojection error over and the corrected points with Levenberg-Marquardt. The normal equations have a sparse structure, so each iteration costs .
- Sampson minimization. Minimize the Sampson error over the 9 entries of only, with Gauss-Newton or Levenberg-Marquardt. It is close to the Gold Standard result when the noise is small.
- Robust estimation. RANSAC and its variants with the 4-point DLT as the minimal solver, followed by one of the methods above on the inliers (HZ Section 4.8, automatic computation of a homography). The general setting is robust model fitting.
- Direct methods. Direct image alignment estimates from pixel values by Gauss-Newton on the photometric error, from a good start.
| Algorithm | Time | Space | Properties | Code |
|---|---|---|---|---|
| Direct linear transformation for homography | Θ(n) worst · average · best | Θ(n) extra | deterministicexactofflineiterative | 1 language |
Bounds
- Minimal data. has 8 degrees of freedom and each pair gives 2 independent equations, so 4 pairs are the minimum. This also sets the size of the minimal sample in RANSAC.
- Cost. Any method reads all pairs, so . The DLT forms a matrix and finds its smallest singular vector in time, since the number of columns is fixed. One Levenberg-Marquardt step of the Gold Standard method costs with the sparse structure.
- Robust sampling. If a fraction of the pairs are inliers, RANSAC needs samples to draw one sample of 4 inliers with probability . For and , .
Reductions
- The algebraic problem reduces to finding the unit vector that minimizes , which is the right singular vector of for its smallest singular value.
- The Gold Standard problem is a nonlinear least squares problem in unknowns.
- Estimating the pose of a calibrated camera that sees a plane reduces to homography estimation followed by homography decomposition; this is the planar case of perspective-n-point.
- Zhang's calibration method reduces camera calibration to estimating one homography per view of a planar target.
Applications
- Image stitching: one homography per pair of overlapping photos, or a rotation per photo.
- Camera calibration from a planar target (Zhang's method).
- Rectification of a photo of a document, a facade or a sports field to a front view.
- Augmented reality on planar markers, and the pose of a drone or a robot above flat ground.
- Image registration of nearly flat scenes, such as aerial photos and document scans.
References
- Richard Hartley and Andrew Zisserman, Multiple View Geometry in Computer Vision, second edition, Cambridge University Press, 2004, Chapter 4, Estimation - 2D projective transformations (Section 4.1 the DLT, Section 4.2 the cost functions, Section 4.3 maximum likelihood, Section 4.4 normalization, Section 4.5 iterative minimization, Sections 4.7 and 4.8 robust and automatic estimation)
- Richard I. Hartley, In defense of the eight-point algorithm, IEEE Transactions on Pattern Analysis and Machine Intelligence 19(6), 1997, 580-593, the normalization of the points before a linear estimate
- Richard Szeliski, Computer Vision, Algorithms and Applications, second edition, Springer, 2022, Section 8.1, Pairwise alignment (least squares fitting of 2D motion models, including the homography)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag T23R2B Edit this page History Report an error Markdown