Project overview

The first part of the project involved warping images using homographies, and then using homographies to rectify images and combining images into a mosaic. Homographies require 8 degrees of freedom, so we need 4 points (minimum) to solve for a homography matrix.

Homography

We are trying to solve for H, using the formulation below (letting i = 1):

Let's say we are trying to morph from image 1 to image 2. Let (x,y) be some coordinate of image 1, and (x',y') be the corresponding coordinate in image 2. After doing some quick maths, we find that

ax + by + c - gxx' -hyx' = x'

dx + ey + f - gxy' -hyy' = y'

If we have 4 correspondences (minimum), we can solve for all the free variables in H. However, we would like to have more points, and use least squares to fit those points, as humans like myself are pretty bad at clicking corresponding points accurately/consistently.

Warp image result

Here, I warp image 1 to fit the plane of image 2. In order for the warped images to display correctly, they must be translated such that all coordinates are positive.

Image 1
Image 2
Warped

Image rectification results

These images were rectified by using known square or rectangular coordinates. For the table, I used a 100x100 rectification. For the light switch, I used a 200x300 rectification

Original
Rectified

Mosaic results

For parts that overlapped, I used a weighted average of both images' pixels, and for the non overlapping parts, I just used the original image pixels.

Image 1
Image 2
Stitched

Conclusions / Coolest things I learned

I thought non-affine transformations would be very difficult, but turns out with one more degree of freedom, we can do morphs! Throughout the entire time we have been learning about image warping, I am starting to get a better understanding on how human vision and perspective works, and how we are able to translate a 2d image on our retina into a 3d perception.