In this assignment, entirely prepared by the fearless David Martin, you will align multiple photographs together using homogrpahy transformations. In the first part, you will do this by manually clicking on corresponding points. In the second part, you will automate this process using SIFT patches and correspondence estimation with RANSAC. A useful reference is this paper on using SIFT for stitching mosaics. The following directory contains the source images for alignment, along with skeleton code:
The first image in each example provided is the central image. It's simplest to construct a mosaic from a central image and a set of peripheral images, since we then need to find just one homography for each peripheral image. Use the cpselect and cpcorr functions to manually select and refine at least 4 pairs of corresponding points in each overlap region between the central and peripheral images. These points should be located on high contrast corners.
Next, compute the homography using SVD for each set of correspondences to provide the mapping from points in the central images and points in the peripheral images. You'll probably want to write two functions such as:
function [H] = computeHomography(x1,y1,x2,y2) function [x2,y2] = applyHomography(H,x1,y1)
Note that the inverse mapping is given simply by inv(H).
1. Use the central image's coordinate system for the final mosaic. You need to figure out the min and max pixel coordinates when the peripheral images are mapped into the central image's coordinate system. Simply apply your homographies to the peripheral images' corner points to find the extent of the final mosaic. Note the final mosaic will be larger than the reference image, and so has a different origin!
2. Now generate a meshgrid of points to cover the mosaic, send these points through each homography in turn, and use interp2 to extract pixel values from the source images. For each input image, this produces an image the size of the final mosaic; pixels that are outside the source image are set to NaN.
Finally, assemble the mosaic from the remapped source images. Use isnan(I) to get a mask for each one that tells you which pixels are valid and which are invalid. For Part I, you may simply take a pixel from any valid image.
This assignment must be submitted electronically to the EEE dropbox. Create a single zip/tar file with your code and final writeup.