Andrew Millman, CS194-26 Project 6

This project involved the concept of homographies, which are essentially matrices that help map points on one picture to corresponding points on a second picture, in the form p'=Hp, where p' are the source points, p are the target points, and H is the homography matrix. In this project, we use the inverse of H to warp images from the source points to the target points both of which are taken from the same center of perspective. This allows us to do 2 things: rectifying images and stitching images to create a panorama / mosaic.

Rectifying

We can rectify an image by creating a homography that lets us transform 4 source points in an image, which make a generic quadrilaterial, to 4 targer points that create a rectangle / square. I took images of objects that are actually rectangular but look skewed due to perspective. After defining the 4 points as the corners of the object in question, I used simple math to transform generate 4 target points that created a rectangle. I first defined the left, top, right, bottom values of the rectangle as the following: left was the x-average of the 2 left points, top was the y-average of the 2 top points, and so on. I then defined the (x,y) corners as (left, top), (right, top), (left, bottom), (right, bottom).
My mirror all skewed
My mirror rectified
Would you like to see game I'm watch?
Here it is

Mosaic

This part also uses ideas of homography to allow us to "stitch" many photos together in a panoramic essence. Essentially, we have three pictures: left, center, and right. We want to warp points on the left and right photos to points on the center photo using the homographic matrices. When selecting the corresponding points, I had two different sets of points (manually selected) for the left + center images vs. the right + center images, simply because if I tried to share the points across all images, that would mean every point I defined in the left image would also have to be in the right image. This made the homographic matrix more susceptible to overfitting and errors. Once I warped the left and right images onto the center image, I concatenated the results together. To make the stitching smoother, I added a gradient to transition the end of one image to the beginning of the next. Below are the results:

Raw images of my room

My room (left)
My room (center)
My room (right)

Warped images

My room warped (left)
My room preparing to get warped on(center)
My room warped (right)

Panorama of my room

The result

Raw images of my street

My street (left)
My street (center)
My street (right)

Warped images

My street warped (left)
My street preparing to get warped on(center)
My street warped (right)

Panorama of my street

The result

Raw images of my kitchen

My kitchen (left)
My kitchen (center)
My kitchen (right)

Warped images

My kitchen warped (left)
My kitchen preparing to get warped on(center)
My kitchen warped (right)

Panorama of my kitchen

The result