CS294-26 Project 4 Image Warping and Mosaicing

Jimmy Xu

 

Overview

The goal of this project is to explore the magic of homography via two of its applications: image rectification and image mosaicing.

 

Shoot and Digitize Pictures

The first step is to take some pictures with the same center of projection (i.e. rotating, but not translating, the camera).

Bathroom

Bedroom

Lewis Hall

 

Recover Homographies

The next step is to annotate the pictures with corresponding points and solve for the homography matrix H. We need at least 4 points.

By definition, perspective projection can be expressed as follows.

[xayaza]=H3×3[x1y11],[x1^y1^1]=1za[xayaza][x^izay^izaza]=[h11h12h13h21h22h23h31h32h33][xiyi1]

I referred to [1] for some guidance to set up the system of equations. I then used least-squares to solve for H. Following this pattern, we can add more points to the giant matrix on the left.

[x1y11000x1x^1y1x1^x2y21000x2x2^y2x2^x3y31000x3x3^y3x3^x4y41000x4x4^y4x4^000x1y11x1y1^y1y1^000x2y21x2y2^y2y2^000x3y31x3y3^y3y3^000x4y41x4y4^y4y4^][h11h12h13h21h22h23h31h32]=h33[x^1x2^x3^x4^y1^y2^y3^y4^]where h33 can be set to be 1

 

Warp the Images and Image Rectification

Once we have the homography matrix, we can warp the image. If we set the destination to be a rectangle, we can make a plane frontal-parallel. I referred to [2] for some help with cv2.remap.

We can do the same thing for a more extreme example

 

Blend the Images into A Mosaic

I can also warp one image to another and blend them, creating an image mosaic. The overlapping region of the two images are the average of them.

 

To be continued...

References

[1] https://towardsdatascience.com/estimating-a-homography-matrix-522c70ec4b2c

[2] https://stackoverflow.com/questions/46520123/how-do-i-use-opencvs-remap-function