CS194-26: Intro to Computer Vision and Computational Photography, Fall 2021

Project 4: [Auto]Stitching Photo Mosaics

Angela Chen



Part A: Image Warping and Mosaicing

Shoot the Pictures

Here are the photos I will be warping and blending into a mosaic:

Sunset taken from my apartment window.


sunset0.jpg.
sunset1.jpg.

Trees taken outside Lewis Hall.


tree0.jpg.
tree1.jpg.

Street and building outside Lewis Hall.


building0.jpg.
building1.jpg.

Recover Homographies

To find the 3x3 homography matrix, H, I set the last bottom-right entry to 1 and solved for the other 8 unknowns using least-squares.

Here is how I derived my least-squares setup:

For the sunset images, I wanted to warp the other sunset images to sunset1.jpg, so I defined corresponding points between sunset1.jpg and each sunset image.


sunset0_points.png.
sunset1_for_0_points.png.

For the tree images, I wanted to warp the other tree images to tree1.jpg, so I defined corresponding points between tree1.jpg and each tree image.


tree0_points.png.
tree1_for_0_points.png.

For the building images, I wanted to warp the other building images to building1.jpg, so I defined corresponding points between building1.jpg and each building image.


buildingt0_points.png.
building1_for_0_points.png.

Warp the Images

Once I have H, I can warp one source image into the perspective of another target image. To find the corresponding source coordinate for each target coordinate, I used the inverse of H to compute an inverse warp with interpolation. I used cv2.remap() to fill in the target pixels after I computed the source and target coordinates.

Image Rectification

To test my warping, I rectified two images into a "front-parallel" or bird's eye view.

Tile in my apartment.


tile.jpg.
Tile points to be put in bird's eye view.

Rectified tile with tile point 1 at image coordinate (0, 0).

Window of Lewis Hall. The original image was very large so I had to resize it to be much smaller, so there's some blurring in the original image.


window.jpg.
Window points to be put in bird's eye view.

Rectified window with window point 1 at image coordinate (0, 0).

Blend Images into a Mosaic

After warping, I attempted to blend my images into a mosaic.

Here's the sunset:


sunset0 warped to sunset1.
The sunset mosaic.

Here's the tree:


tre0 warped to tree1.
The tree mosaic.

Here's the building:


building0 warped to building1.
The building mosaic.

Tell Us What You've Learned

The coolest thing that I've learned in this part is the power of the homography matrix. With at least 4 corresponding points for each image, you can transform one image into the perspective of another image. I think that's so fascinating and shows the power of matrices and linear algebra!