Project 4A: Image Warping and Mosaicing

CS194-26 Fall 2021

Part 1: Shoot the Pictures

Before CS194-26 lecture, I ventured outside of Lewis Hall through the back doorway near Pimentel Hall and snapped these photos. I'm not even sure what building this is, but it's one connected to part of Lewis Hall. I picked these images because of the unique architecture present, as well as the plenty of corresponding points to choose from.

Part 2: Recover Homographies

Now, I need to compute the homography used to transform pairs of points. In our setup, our homography H is a 3x3 matrix with 8 degrees of freedom (we fix the bottom right corner to be 1). We can solve for this homography using 4 pairs of points, but for stability purposes, I chose 8 pairs of points to find H using Least Squares. Below is the least squares setup I used to find H. This can be extrapolated to more than 4 points by including the appropriate equations in the matrix as well.

My implementation for this method can be found in my code. Credit to this equation goes to this incredible source.

Part 3: Warp the Images

With the ability to now recover homographies, I'm able to warp images now. Below, I show the "right-side" image of the building warped into the orientation of the "left-side" image.

Part 4: Image Rectification

In this method similar to image warping, I selected four points of an image that I know to be planar, and then computed the homography from those selected points, to points that form a rectangel. I show the previous image, and then the rectified images below.

I think this rectification looks really neat!

Part 5: Blend the Images into a Mosaic

Finally with all the above, I'm able to blend the images I've taken into a mosaic! Below, I show the two padded and warped images, before being combined into a mosaic. For my stitching, I use what I've learned in Project 2 with Laplacian Pyramids. I also use a mask that only blends the image at points where pixels from both images are present, and otherwise just use the ground truth pixels from the corresponding images.

Part 6: What I've Learned

From this project, I've learned a lot about how to change and warp an image just using a simple 3x3 matrix! It was really cool to see the application of these homographies in class to look at how tiles in old paintings would look, after rectifying the image. Overall, this was a really cool application that I was able to implement and see work from scratch.