Project 5: [Auto]Stitching Photo Mosaics

Jie Qiu

Part 1

1. Shooting Pictures

Here are the two pictures that I shoot for image rectification

book
soda

And here are the ones that I took for image mosaic.

im1
im3
building1
building2
window1
window2

Since I do not have a tripod, I used my arm as a tripod (I put my elbow

2. Recover homographies

I used the following equation found online for reference. I got rid of the last column of P and h9, and defined the right hand side to be the negative of the last column of P. This is to avoid python giving back a matrix of all zeros. I created an over-determined system by defining 8 corresponding points, and used np.linalg.lstsq to compute the homography matrix.

h

3. Warp the Images

For this part, I defined a python function to warp a given image according to a homography matrix. Since some pixel locations will map to negative coordinates, I expanded the canvas size to be 1.5 times as before on each side. And because the original warped image might be bigger than the original image, which can result in pixels with no values, I also downsampled the warped image every 2 pixels.

4. Image Rectification

book
book_rectified
soda
soda_rectified

5. Blend the images into a mosaic

For the outdoor mosaic, I defined the points to be: white car wheels' centers, blue car wheels' centers, and the four corners of the shopping window. I warped both images. For the building mosaic, I defined the eight points to be the four corners of a wood panel and four corners of the door, and I warped the first image to the second. For the window mosaic, I defined the eight points be the corners of the window as well as those of the smaller rectangle on the window.

I identified the start and end x coordinates of the overlapping regions, and defined an alpha channel over that region to blend the two images. i.e. The alpha value decreases from 1 to 0 linearly in the overlapping region from left to right, and each column's pixels are defined by alpha * warped_im1 + (1 - alpha) * warped_im2.

building_mosaic
Outdoor
building_final_cropped
Building
window_final
Window

However, we can see that the outdoor and the window mosaic gets a little blurry at the tree. I believe this is partially because my arm was not steady enough, and the window was a close object, and partially because Berkeley was windy and the branches shook as I was taking the picture

6. Tell us what you've learned

I learned from this assignment how cool homographies are, and how we can use an overdetermined system to reduce the risk of getting an error.