HW5: Homography mosaics

Due March 14 in EEE DropBox at 11:59 pm


HW5: Homography mosaics


Mosaic of 4 images aligned with homographies

In this assignment, you extend the field of view of a camera by forming a mosaic from multiple photographs. When images are taken with same optical center, they can be aligned with a homography transformation. To estimate the homography, you'll need 4 pairs of corresponding points in the overlap region. You'll mark these points manually. We discussed in class some methods for finding them automatically. The following directory contains the source images for alignment, along with skeleton code:

Programming: [75 points]

  1. Warping: [50 points]

    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 linear least squares 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).

    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.

    Now generate a meshgrid of points to cover the extent of the final mosaic, and send these points through each homography in turn to map them back to the source images, 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.

  2. Blending: [25 points]

    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. The simplest approach is to just to paste down the pixels from each image in turn. However, as we discussed in class this can lead to bad artifacts. Instead you should create a blend between the images. If you construct the mosaic sequentially by each time adding a photo to the existing mosaic then you only ever have to deal with blending a new photo into the mosaic. However, this will still take some creative thought on your part to figure out a nice way to perform a weighted blend between pairs of images where they overlap. You will probably want to refer back to lecture 12 for ideas. I will award extra credit to anyone who succesfully implements 2-band or Laplacian blending.

Writeup: [25 points]

  1. Show the resulting mosaic for one of the provided examples. Show also the remapped source images before they are blended into the final mosaic.

  2. Show two mosaics of your own creation, each with at least 3 source images. You should use your own camera to take images. Remember that you want to keep the camera center in the same location and simply rotate the camera. For your writeup, show also the remapped source images before they are blended into each final mosaic.

Matlab Tips

  1. Don't forget the hold on command if you want to plot one thing on top of another.

  2. Running cpselect is a pain. Don't do it more than once for any pair of images! You can use the save and load functions to save and restore variables from your matlab workspace.

  3. Do no use the full size images. Resize them down so that your debugging goes fast. For your final results, 25% size is sufficient.

  4. You can treat the central image as just another source image by using eye(3) as its homography.

Extra-credit

As detailed in the guidelines, any project handed by 11:59 pm on the previous day will recieve 10% (4 points) extra credit. Assignment original prepared by David Martin.