Homography Estimation
Homography estimation solves the 3 by 3 matrix that maps one plane to another, so tilted documents flatten and photo pairs align.
Why Does This Exist?
Two photos of one flat surface differ by perspective, not just shift and zoom. Posters, documents, courts, and walls need a plane to plane map before they can merge or measure. The homography is that map.
Estimation turns matched keypoints into with the Direct Linear Transform inside RANSAC. For transform basics, read image transformations and homography first.
Think of It Like This
Pinning a poster flat
A poster photographed at an angle looks like a trapezoid. Pin its four corners onto a rectangular frame and the print flattens. Each pin constrains the stretch.
Point pairs are those pins. Four good pins define the warp, extra pins steady it. The analogy stops at depth: pins assume one flat sheet, while curved or multi depth scenes need richer models.
How It Actually Works
A homography maps homogeneous points to up to scale:
Eight degrees of freedom need at least four point pairs. DLT builds two rows of matrix per pair from and solves by SVD. Normalize points to first for stable math, then denormalize. RANSAC wraps DLT to reject outliers.
Worked numbers
Map source corners , , , to square , , , . Four pairs give an matrix . SVD returns up to scale with . A fifth pair at mapping near then reprojects within pixels when is right, counting as an inlier at threshold . Final is refit on all inliers and warps source to destination with inverse sampling plus bilinear interpolation.
Watch Out For
Solving from collinear points
Four points on one line leave perspective underdetermined, and DLT returns wild warps. Check point spread and reject samples with tiny area before solving.
Using one homography off the plane
models one plane or pure rotation only. Foreground chairs against a back wall break it. Segment planes or move to epipolar geometry when depth varies.
The Quick Version
- A homography has eight degrees of freedom with fixed to one.
- Four point pairs give a minimal DLT solution.
- Normalize points before SVD for stable results.
- RANSAC plus reprojection threshold handles outliers.
- Warp with inverse mapping and interpolation for clean output.