CS194-26 Project 6

Isabel Zhang: cs194-adi

Project Overview

This project used homography to rectify and stitch images manually.

Given two images, A and B with their corresponding points pts_A and pts_B. Each image has at least 4 given points as with 8 sets of points total, the matrix can be resolved. Using p' = Hp, where H is the transformation matrix that transforms p to p'. A crucial part of the project is to compute the matrix H.



Image Rectification

The goal for this section was to refocus the image at different focal depths within the image.

Implementation

  1. Input: image with 4 corresponding points defining a square/quadrilateral
  2. Create pts_2 array created as a square: [(0,0), (0,1), (1,1), (1,0)].
  3. Compute H using input image points and pts_2 array.
  4. Warp input image according to matrix H

Results

Original Image
Rectified Tile with Soap
Original Image
Rectified Map
Rectified Map All


Part 2: Image Stitching

Given 2 images, stitch the images together. This involved calculating the offset and conducting linear blending.

Implementation

  1. Given two images A, B and corresponding points, calculated the H matrix
  2. Calculated the translation offset
  3. Warp with the inverse(translation.dot(H))
  4. Average/feather images together. I calculated the center of A and B (with translation's) corners. Then, calculated the center of the new image. Finally, I calculated the percentage of A and B to use depending on their distance from the centers

Results

Stitched Mosaic: Seattle Ferris Wheel

Input Image 1
Input Image 2
Note the overlap lines on both sides of the ferris wheel
Blended using Weighted Averages
Input Image 1
Input Image 2
Panoramic direct overlap
Panoramic with averaged blend (slightly different point set)

The input images were already blurry so after warping, the effect of the blur was much stronger. The feathering blend did not fair much better here and a ghosting effect still occurs.

Input Image 1
Input Image 2
Panoramic stairs with averaged blend


Summary

In this project, I learned how to use homographies to alter image perspectives. The image rectification portion was the most interesting. I've used apps like camscanner in the past which seem to be able to magically transform images from one angle to the next. Having learned the mathematical principles behind it, I've come to appreciate the app even more.