Homography and Image Mosaicking
When a camera looks at a flat surface, or rotates without moving, two images of it are related by a homography: a 3 by 3 matrix that maps every pixel of one image to the other. Four point pairs are enough to find it. Stitching photos into a mosaic or a bird's-eye view uses exactly this.
Drag the four red corners.
The homography
Points are written with an extra 1, and the homography \(H\) maps them up to a scale factor:
\(H\) has 8 free numbers, since its overall scale does not matter. Each point pair gives two equations, so four pairs are enough. This page solves the resulting 8 by 8 system, the direct linear transform, every time you move a corner.
What to notice
Drag the corners into a trapezoid and the image tilts away like a floor seen in perspective. Straight lines stay straight, but parallel lines can meet, and distances and angles change. A robot can use the inverse of the same matrix to turn a camera view of the floor into a top-down map, called inverse perspective mapping. For panoramas, homographies from feature matches let one image be warped onto the next and blended.