Project 5 [Auto]Stitching Photo Mosaics

Lizhi(Gary) Yang

Part A

Shoot and digitize pictures

Here are the photos I shot for the project:




Recover homographies

First I define the 4 points in each image with the ginput function of matplotlib. Then I construct the A matrix and b vector in order to solve a least-squares problem with the form Ah=b for the unknowns in the homography matrix, where for one point:

A=[[x2, y2, 1, 0, 0, 0, -x1x2, -x1y2].
       [0,0,0,x2,y2,1,-y1x2, -y1y2]]
b=[[x1],
      [y1]]

After I get h, I reshape it into a 3 by 3 matrix and the last element is 1. The homography matrix is as follows, where H is the result of the least squares.

[[H[0], H[1], H[2]],
 [H[3], H[4], H[5]],
 [H[6], H[7], 1.]]

Warp the images

After I have the homography matrix I am able to rectify images with inverse warping, here are 2 examples of rectification, left is original and right is result:

Blend images into a mosaic

Blending is done with alpha blending and a cosine function evaluated from 0 to pi/2 over half the image for the values of alpha - since we want to gradually move from the first image to the second. Here are 3 mosaics with the original images on the left and the result on the right:










Bells and Whistles

Video mosaic

I used my phone and borrowed a friend's device to record the flow of the water fountain. On the left are the original videos and on the right is the mosaic. I handheld the devices so the video is not that stabilized.