
CS180 Project 4A: Image Warping and Mosaicing
Author: Nicolas Rault-Wang (nraultwang at berkeley.edu)
Credit to Notion for this template.
1. Recovering a Homography
We begin by explaining how we estimate the homography transformation matrix to map into the geometry of .
Two images and with the same center of projection are related by a homography. To estimate this transform, we first need to label a set of feature correspondence points between both images.
Note that must be at least 4 because homographies have 8 degrees of freedom due to scale invariance andeach pair of correspondences provides two constraints on .
1a. Establishing Point Correspondences
The figure below shows some example pairs of correspondence points. Well-defined edges are excellent features to correspond because they are easy to identify in both images.

1b. Estimating the Homography
While a minimum of 4 correspondence pairs are required to solve for , this system is very sensitive to noise. To produce a more robust homography, we use more than 4 correspondence pairs to form an over-determined system, then use least-squares to obtain an estimate of the free parameters of .
Working in homogeneous coordinates, the derivation of two equations constraining the free parameters of from an arbitrary correspondence pair is straightforward:
Stacking all equations into an feature matrix and target vector gives
where we have unrolled into .
For well-chosen correspondence points , the columns of are linearly independent, making have full column rank. Hence, the least-squares estimate of , and thus , is uniquely given by
2. Warping Images with a Homography
In all following sections, we’ll use the term “canvas” to refer to an -axis aligned bounding box that is large enough to contain all points in the image of the homography transform.
2a. Warping One Image

With the homography relating and , we map into with an inverse warping procedure:
- Determine the minimum dimensions of the canvas by warping the corners of into .
- For every canvas pixel in the quadrilateral formed from the warped corners of , compute the point in the geometry of by inverting the homography.
- In general, will not lie exactly on a grid point in , so we interpolate the RGBA color vector at from the grid points of . Our code uses
scipy.interpolate.RegularGridInterpolatorto do this.
- After completing steps 2 and 3, we have the color value at each canvas point , completing the process of inverse-warping to the canvas with , producing in the geometry of .
- To avoid edge-artifacts, we use a 2-level laplacian pyramid to smoothly blend and .
- We found that a mask created from the Euclidean distance transform on and works very well. Our code uses
scipy.ndimage.distance_transform_edtto do this.
- We found that a mask created from the Euclidean distance transform on and works very well. Our code uses
2b. Image Rectification
An application of homography warping is undoing (rectifying) the perspective distortion of rectangular objects in images. This is theoretically possible because two images of a planar rectangular-looking object, like a tile or poster, are related by a homography.
Below, we show some examples of this operation. The image on the left is the original and the image on the right is the result of rectification.
3. Creating Panoramas
We can extend our one-image warping procedure to create panoramas. Since two images with the same center of projection are related by a homography, we can form a panorama by warping a set of images with the same center of projection into a particular image in this set. This can be implemented by recursively applying the the one-image warp to grow a panorama one image at a time.





























