Introduction
This project explores how to use homographic transformations to stitch together a photo mosaic. As well, we use homographic transformations to warp images to rectify shapes to seem like they are from a different point of view.
Raw Images Used
These are some of the raw images I used in this project.
.jpeg)
Berkeley Way West Bottom

Berkeley Way West Top

Pranav Left

Pranav Right

SF Skyline Left

SF Skyline Right
Recovering Correspondences
I used a GUI to manually select correspondences between the two images. This was done by clicking on a point in one image and then clicking on the corresponding point in the other image.
This is an example of one of the images with the correspondences marked.

Pranav Left Points

Pranav Right Points

Berkeley Way West Bottom Points

Berkeley Way West Top Points
Computing the homographic transformation
The homographic transformation is computed using the following equation:
Where H is the homography matrix, p is a point in the source image, and p' is the corresponding point in the destination image.
Expanding this out, we get the following equation:
Expanding this out further, we get the following equations:
Reframing this so that we can use the new points and old points to solve for the homography matrix, we get the following equations:
To reduce the chance of overfitting, we can use more than 4 points and then solve this system of equations using least squares to get the homography matrix.
Warped Images
Here are some of the warped images I got from this technique.

Berkeley Way West Top

Berkeley Way West Bottom Warped into Top

Pranav Left

Pranav Right Warped into Left

SF Skyline Left

SF Skyline Right Warped into Left
Blending Images
To blend the images, we create a mask that is the same size and shape as the warped images. Then, to ensure a smooth transition, we use a dissolve factor that changes linearly with the distance from an images edge from 0 to 1. We then use this mask to blend the pixels of the two warped images together, normalizing the pixels by the mask so that the brightnesses are correct.
Here are some of the blended images and the corresponding masks I got from this technique.
Berkeley Way West

Anchor Alpha Mask

Warped Alpha Mask

Blended Images
Pranav

Anchor Alpha Mask

Warped Alpha Mask

Blended Images
SF Skyline

Anchor Alpha Mask

Warped Alpha Mask

Blended Images
Rectifying Images
To rectify images, we can use the homography matrix to warp the image to a new point of view. This is useful for things like correcting perspective shift in photos.
Here are some of the rectified images I got from this technique.

Original Tiles

Original Tile Points

Target Tile Points

Rectified Tiles

Original Presentation Screen

Original Presentation Screen Points

Target Presentation Screen Points

Rectified Presentation Screen