CS 194-26 Project 6A

IMAGE WARPING and MOSAICING

Quinn Tran (abu)


Recover Homography + Warp the Images

To compute homograph transition matrix, I selected correspondence points from 2 image manualy. I use at least 4 pairs of points to solve for H:

Don't forget to divide w (or the third dimension of the transformed coordinates) to get x', y'.

Image Rectification

Warp the image into the plan we want using our calculated homography matrix H. Here, I warped images to the target image/plane that was going to be the center of my mosaic. My target image is the middle image. An inportant step was to compute the boundary of the bounding box via the 4 corners of the unwarped image.

Before

left, middle, right

After

left, middle (unwarped), right. The pottery in each image is now seen from the same perspective (size not considered)

Before

left, middle, right

After

left, middle (unwarped), right. The tree next to the closest flag and both flags are now seen from the same perspective (size not considered)

Before

left, middle, right

After

left, middle (unwarped), right. The leftmost arched entrance is now seen from the same perspective (size not considered)

Blend the Images into a Mosaic

I first started to combine two images as a time, having the middle image in each scene as the target perspective. I used cv2.warpPerspective with my image, calculated H, and warped bounds to calculate a mosaic of 2 images. Then, we only have to set a certain area of the warped image with the pixel values of the target image. This only worked when the right image was being warped. I had a hard time manipulating my bounds so that a warped image on the left would also line up with the target image on the right. In this case, I first created masks of the region of interest for each image. Then, I used linear blending (a linear combination) on the regions of interest for both images to create the resulting image. It was tricky getting the bounds correct to align in this case.

left warped, right warped

left warped, right warped

left warped, right warped

Mosaic with 3 Images

I combine my left and right mosaics to create a panorama via 3 images. I use the bounds of the target image from each smaller mosaic to align both the left and right into the panorama. Once again, it was tricky getting the bounds of the target image (from each smaller mosaic) to line up and have the rest of the picture "look right". Various reasons are explained below.

The changing shadows from different perspectives resulted in some discoloration. We can also see the wildly different perspectives from manually taking pictures of my beautiful handmade pottery.

It was tricky getting the bounds correct to align when the left image is the warped image.

Here we notice the extra dimension/variable to stepping closer to hearst mining while taking photos, resulting in seeing a blurred version of a smaller hearst mining building or a larger hearst mining building.

Overall, I still think they lined up pretty well. More correspondence points and less user error during manual picture taking would have been nice.

Reflection

This project was super cool and confusing because I kept using the forward verses backwards homography H. I also got a better intuition of filters and pixel value interpolation to make a mosaic. I didn't expect a warp to create such a focused image (bounded by correspondences). It would be interesting to try more clever ways to mosaic more than 2 images together.