Skip to content
AI360Xpert
Beta

Homography Estimation

Homography estimation solves the 3 by 3 matrix that maps one plane to another, so tilted documents flatten and photo pairs align.

Homography estimation maps four source corners to a rectangle and warps the plane.
Homography estimation maps four source corners to a rectangle and warps the plane.

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 3×33 \times 3 homography HH is that map.

Estimation turns matched keypoints into HH 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 xx to x′x' up to scale:

x′∼Hx,H=[h11h12h13h21h22h23h31h321]x' \sim H x, \quad H = \begin{bmatrix} h_{11} & h_{12} & h_{13} \\ h_{21} & h_{22} & h_{23} \\ h_{31} & h_{32} & 1 \end{bmatrix}

Eight degrees of freedom need at least four point pairs. DLT builds two rows of matrix AA per pair from x′×Hx=0x' \times Hx = 0 and solves Ah=0Ah = 0 by SVD. Normalize points to [−1,1][-1, 1] first for stable math, then denormalize. RANSAC wraps DLT to reject outliers.

Worked numbers

Map source corners (56,65)(56, 65), (368,52)(368, 52), (28,387)(28, 387), (389,390)(389, 390) to square (0,0)(0, 0), (300,0)(300, 0), (0,300)(0, 300), (300,300)(300, 300). Four pairs give an 8×98 \times 9 matrix AA. SVD returns hh up to scale with h33=1h_{33} = 1. A fifth pair at (200,200)(200, 200) mapping near (150,155)(150, 155) then reprojects within 22 pixels when HH is right, counting as an inlier at threshold 33. Final HH 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

HH 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 h33h_{33} 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.