Here are the photos I will be warping and blending into a mosaic:
Sunset taken from my apartment window.
Trees taken outside Lewis Hall.
Street and building outside Lewis Hall.
To find the 3x3 homography matrix, H, I set the last bottom-right entry to 1 and solved for the other 8 unknowns using least-squares.
Here is how I derived my least-squares setup:
For the sunset images, I wanted to warp the other sunset images to sunset1.jpg, so I defined corresponding points between sunset1.jpg and each sunset image.
For the tree images, I wanted to warp the other tree images to tree1.jpg, so I defined corresponding points between tree1.jpg and each tree image.
For the building images, I wanted to warp the other building images to building1.jpg, so I defined corresponding points between building1.jpg and each building image.
Once I have H, I can warp one source image into the perspective of another target image. To find the corresponding source coordinate for each target coordinate, I used the inverse of H to compute an inverse warp with interpolation. I used cv2.remap() to fill in the target pixels after I computed the source and target coordinates.
To test my warping, I rectified two images into a "front-parallel" or bird's eye view.
Tile in my apartment.
Window of Lewis Hall. The original image was very large so I had to resize it to be much smaller, so there's some blurring in the original image.
After warping, I attempted to blend my images into a mosaic.
Here's the sunset:
Here's the tree:
Here's the building:
The coolest thing that I've learned in this part is the power of the homography matrix. With at least 4 corresponding points for each image, you can transform one image into the perspective of another image. I think that's so fascinating and shows the power of matrices and linear algebra!