How this calculation works
A planar homography maps projective points between two coordinate planes and can represent perspective changes beyond translation, rotation and uniform scaling. Four point correspondences in general position determine its eight effective degrees of freedom. This calculator solves the homogeneous coefficient system exactly over the rationals, verifies all four correspondences and reports an inverse. It does not force the bottom-right coefficient to one, because valid maps can have that coefficient zero. A query whose output denominator vanishes is reported as a point at infinity rather than divided by zero.
s(x′,y′,1)ᵀ=H(x,y,1)ᵀ; H is an invertible 3×3 matrix defined up to a nonzero scalar.A worked example
Map source square vertices (0,0),(1,0),(1,1),(0,1) to rectangle vertices (0,0),(2,0),(2,1),(0,1). One normalized homography is H=diag(1,1/2,1/2), equivalent up to scale to diag(2,1,1). The finite coordinate map is x′=2x,y′=y, so query (1/2,1/2) maps to (1,1/2). The inverse map divides x′ by two. A general perspective input introduces nonzero denominator coefficients; the same homogeneous method handles those without assuming the map is affine.
Good to know
Exactly four rational source/destination pairs, each frame with no three collinear, and 1–100 query points. Exact coefficient and fraction-growth limits apply. Returns one scalar-normalized invertible H and its exact inverse; different nonzero scalar multiples represent the same projective map. No noisy least-squares fit, robust outlier rejection, camera calibration, lens-distortion correction, image resampling or guarantee that a mapped polygon remains in a finite affine chart.
Reference: OpenCV — planar homography and homogeneous coordinates (opens in a new tab) ↗
Homogeneous scale is part of the representation
A finite Cartesian point is represented by a nonzero homogeneous vector (x,y,1), and multiplying that vector by a nonzero scalar does not change the point. The matrix also has an arbitrary common scale. The calculator normalizes one nonzero coefficient for reproducibility, not because that coefficient has a special geometric value. Comparing raw matrices from two systems therefore requires allowing a common scalar before declaring them different.
After multiplying H by a query vector, divide the first two coordinates by the third only when that denominator is nonzero. A zero denominator represents a direction at infinity. Invertibility ensures the homogeneous output vector itself is not zero. This distinction lets the tool handle maps whose horizon crosses the input plane, rather than dropping problematic queries or clipping their coordinates to a large artificial value.
Four correspondences must form valid projective frames
Three collinear source points cannot be freely matched to an arbitrary noncollinear triple by an invertible homography, because projective maps preserve collinearity. Repeated points also fail to supply independent constraints. Requiring no three collinear in either four-point frame gives a clear unique-up-to-scale problem. The calculator checks this condition exactly with rational determinants before solving the homogeneous nullspace.
A homography preserves lines but generally changes angles, parallelism and distance ratios along different directions. It is not a rigid alignment or an affine-only fit. The Orthogonal Procrustes 2D alignment calculator optimizes a shape-preserving transformation, while this page solves an exact projective correspondence problem. For noisy measured points, an exact four-point solution can amplify errors; fitting more points with a declared statistical or robust method would be a separate operation.
A few questions, answered
Why is the reported H not the same scaled matrix I expected?
Multiplying every entry of H by a common nonzero scalar gives the same projective map. Compare mapped points or normalize both matrices consistently.
Can I enter a noisy set of ten matching points?
Not on this exact four-pair page. A noisy overdetermined fit requires a declared estimation method; this solver does not silently choose four rows or perform least squares.