Homography and Projective Transformation
Source: CS1674 Ch.6. A single view is ambiguous in depth; multiple views resolve 3D. This chapter covers 2D transformations, homogeneous coordinates, the homography (projective warp), panorama stitching, and how to estimate
from correspondences (2D-DLT) with RANSAC.
1. Why Multiple Views?
Structure and depth are inherently ambiguous from a single image. Two (or more) views of the same object let us recover geometry. The alignment problem: given matched feature pairs
2. 2D Transformations
A transformation is a coordinate-changing machine
2.1 Linear 2D transformations (2×2)
These are combinations of scale, rotation, shear, mirror — but not translation.
| Transform | Matrix | Effect |
|---|---|---|
| Scaling (uniform) | Multiply both axes by | |
| Scaling (non-uniform) | Different scale per axis | |
| Rotation | Rotate about origin; | |
| Shear | Slant | |
| Mirror (Y-axis) | Flip | |
| Mirror (origin) | Rotate 180° |
2.2 Translation needs homogeneous coordinates
Translation
So a 2D point is represented by a 3-vector; to recover image coords divide by
2.3 2D Affine transformations (3×3)
Affine = linear transform + translation. Written in homogeneous form with last row
Properties: maps lines to lines; parallel lines stay parallel.
2.4 2D Projective transformations — Homography (3×3)
Projective = affine + projective warp. General 3×3 matrix:
A homography is a mapping between two projective planes with the same center of projection. Parallel lines need NOT remain parallel (they meet at a vanishing point). Also called a projective transformation.
Hierarchy: Linear ⊂ Affine ⊂ Projective. Degrees of freedom — Linear 4, Affine 6, Projective (homography) 8 (after fixing scale).
3. Panorama Stitching — Motivation
When the camera rotates about its optical center (no translation), the images are related by a homography. Stitching them reprojects all images onto a common plane, forming a synthetic wide-angle view (mosaic).
Basic procedure
- Capture a sequence from the same position, rotating about the optical center.
- Compute the homography between consecutive images.
- Warp/compose images onto a common canvas.
- Blend to create the mosaic.
- Repeat for more images.
4. Computing the Homography (2D-DLT)
Given
For one correspondence
Cross-multiplying gives two linear equations in the 8 unknowns:
Stack all
Solving
- Overdetermined (
): least squares . - Homogeneous form (don't fix
, use ): the solution is the unit-norm eigenvector of with the smallest eigenvalue:
This is the classic Direct Linear Transform (DLT).
5. Applying a Homography (Image Warping)
Given
5.1 Forward warping
Send each pixel
5.2 Inverse warping (preferred)
For each output pixel
6. Dealing with Outliers: RANSAC for Homography
Matched points always contain errors/outliers. RANSAC:
- Sample 4 matched pairs, compute
. - Warp image 1 by
; measure reprojection error for every point. - Count inliers (error < threshold).
- Repeat; keep
with most inliers; refit with all inliers. (Hough voting on translation is the simpler special case when only is unknown.)
7. Assembling the Panorama
- Chain stitching: img1
img2 img3 … Each is a pairwise homography. Simple but error accumulates (drift). - Drift correction: add a copy of the first image at the end and optimize global homographies
(to the plane of the first image) so the loop closes. This removes accumulated misalignment. - Blending: seamlessly combine overlapping regions. Simple method — feathering:
(a linear cross-dissolve across the overlap). More advanced: Laplacian pyramid blending (Ch.3).
8. Summary
| Concept | Key point |
|---|---|
| Homogeneous coords | Encode translation as matrix mult via |
| Affine | 3×3, last row |
| Homography | 3×3 general; 8 DOF; relates views from same center |
| Estimation | 2D-DLT, ≥4 correspondences, least squares / smallest eigenvector |
| Warping | Prefer inverse warping + interpolation |
| Robustness | RANSAC to reject outlier matches |
| Mosaic | chain + drift correction + feathering blend |
Bottom line: write 2D transformations as matrix–vector multiplies in homogeneous coordinates; fit them from correspondences; use RANSAC; stitch via homography + inverse warping + blending.