CS 194 Project 5: Image Stiching and Photo Mosaics

Yibin Li, April 2020

Part A

Shoot the pictures

Before we could stich images and do a photo panaroma, we need to take some source images. Here are two pictures I took last year in Cusco, Peru. I actually took four images like these two but I will save that to part B. :)

jpg

jpg

Recover Homographies

In order to do a successful photo mosaic, we need to take projective pictures of a scene, meaning that all pictures were taken on a "tripod", a fixed center. Otherwise, we will not be able to stich them perfectly.

In this part, we will compute the transformation matrix between one image to the other. This matrix is called the homography. In order to find the homographies matrix, I labeled 6 pair of correspondance points on two images. Then based on these characteristic point, I am able to find the homographies matrix. Finally, I can warp the image using the homographies matrix to the desired final location. Note that the warped image is 1.25 times wider than the original image; this is to account for the extra width of the mosaic image.

Images with corresponding points

png

Image warping

png

Image Rectification

We could use the homographies matrix to see the object in a different perspective! Here I took some random pictures of different objects and rectified them to a perspective other than I took.

png

png

Image Mosaic

With all above, we could stich the image to form a good mosaic! However one problem in the stiching is the sharp color/edge differece between two images. In order to smooth this edge transition, I used image pyramid to blur and darken the part where two images connect. There are some blurry on the final mosaics due to the correspondence point issue, but overall the mosaic looks good!

Full Mosaic

png

Part B

In this part, we will create a system that automatically finds the corresponding interest points and stichs the iamges. I will use four pictures I took from the same place, and try to create a final majestic panorama.

1. Harris Interest Point Detector

The interest points we use are multi-scale Harris corners. Here are the results (code from Professor Efros).

png png png

2. Adaptive Non-Maximal Suppression (ANMS)

Since the computational cost of matching is superlinear in the number of interest points, it is essential to restrict the maximum number of interest points extracted from each image. Therefore, we applied Adaptive Non-Maximal Suppression to all the interest points to reduce the pool of feature points.

png png png

3. Feature Descriptor Extraction and Feature Matching

Once we have determined where to place our interest points, we need to extract a description of the local image structure that will support reliable and efficient matching of features across images.

png png png

4. 4-point RANSAC

This step is to make sure that outliers are removed. For this part, I implemented RANSAC. In each iteration, 4 pairs of matching feature points are sampled randomly, and their homography matrix were calculated by the computing homography function. Then I compared the transformed points difference with its original points, and remove the points where their squared difference is larger than 0.5.

png png png

5. Compute Homography Matrix

Use the same function from part A again, we could compute the warped images.

png png png

Final result of automatic stiching

p1 - p2

png

p2 - p3

png

p3 - p4

png

Put All Together!

This final piece is done by stiching four pictures one by one. Although it is blurry in some part (blending is not perfect), it is very cool! png

What have you learned?

I have used the automatic panorama function on my phone many times, but untill now I understand how it (potentially) works!