# Programming Project #6a - Homographies and Image Stitching

## Overview

Fundamentally, this project relied on using homography warps to stitch multiple images together. The algorithm was determined by the following steps:
1. Taking a set of images without any translational shifts
2. Defining Point Correspondences between images
3. Computing A Homography between two images
4. Applying the homography using an inverse warp to generate a shifted image
5. Combining the shifted image with another image to generate a stitched panorama

## Homography Detection

We use the following homography computation algorithm to evaluate the homographies between our sets

The starting and ending coordinates were defined as such:

 Blue coordinates representing original points and orange representing destination coords Point Labeling Homography Detection

### Rectification and Warping

In order to rectify an image, we simply defined a set of points on the surface of the image and a set of points we wished to map this surface into. We then used inverse warping to apply a homography matrix onto each point.

 Starting Warp location Laptop Rectification Zellerbach being Warped Figure After Warping to the points above

### Image Stitching

Once one of the images were rectified we could stitch it together with the other images of a panorama to create a smooth mosaic of the combined images. The following are the resulting panoramas created using several separate images. Care was taken not to translate the camera along any other axis in order to ensure images were purely rotational shifts of each other.

 A Panorama Stitch of My Apartment A Panorama Stitch of Haste Street A Panorama Stitch Zellerbach Hall

Note that in the final stitch of zellerbach though the homographies did align most of the image, only 8 points were selected to compute homographies and thus there remain artifacts in the final image. In order to stitch the images together, we used a Gaussian blending technique. A mask was generated with ones on one side of the divide and zeros on the other and the images were blended together by using

(1-g_r) * side_1 + (g_r) * side_2

### What I've Learned

Fundamentally, Panorama stitching relies heavily on establishing point correspondences and homographies between images. Once a homography is established it is fairly straightforward to take the image overlay it on a different image and find the optimal "fit" between those images. Homographies, however, tend to be relatively succeptible to improperly chosen points. The process is also heavily reliant on ensuring that the only shifts are rotational and not translational. While completing the project, I attempted the same stitching process with translated images ( where the targets of each image were not extremely far away) and the alignments almost never worked.