Image Warping and Mosaicing

Avni Prasad, CS194-26-aej

Overview

In this project, I take pictures and perform homographies on them to warp them. These projective transformations allow me to accomplish rectification and morphing of images into a mosaic.

Recovering Homography

After taking photos from the same point of view, I want to transform the images into the right shape so that they could be stitched seamlessly together. In other words, given an point (x,y) in image 1, we want to find its corresponding point in image 2 (x',y').


To find the matrix H, we need find a series of correspondences such that a point (x,y) in image 1 corresponds to a point (x',y') in image 2. Once we have the correspondances, we can set up the system of equations below for each correspondance to find the values of H.


We would only need 4 points to give us to determine matrix H, since there are 8 degrees of freedom. However, in my solution, I offer more points to create an overdetermined system to solve for the homography matrix in order to decrease the effect of noise. To solve an overdetermined system, we solve for the matrix with the least squared error.

Warping and Rectification

With the idea of homography, I can now transform the image into any shape within the scope of perspective transformation. With a homography matrix, I can now map every pixel from one image to be seen from the perspective of the other image. This gives opportunity to use warping to rectify images. For example, if we have an image that is taken slanted or from a side angle, I can rectify it finding the transformation matrix that takes the four corners of the a square in the image into a square coordinates.

Here is an example of rectifying an album cover from a photo of my wall taken from a side perspective:

Side Perspective
Rectified Perspective

Mosaic Images

Above, we showed how we can warp shapes in an image to say a square. Now, we want to attempt warping image shapes to match with the images we want to stitch together into a mosaic. We can do this by choosing correspondence points between two images that correspond to the same points. For example, in the images below, I can use the corners of the Beatles poster to match coordinates and perspectives in the two images:

Left Side of Room
Right Side of Room

Then, using these correspondence points, we can determine the homography matrix and warp one image so it mimics that perspective of the other image and the two images can then we overlayed on each other. Finally, stitching together these images can produce a panorama image.

Reflections

This project gives incredible insight on how features like panoromic imaging works on our phones. One thing I was surprised by is how much information is actually encoded in images. This became clear in the rectifying exercise. I was surprised the album cover could be so perfect recreated, even when it was hard to visually see the cover art in the image.