CS194-26 Project 5 - Eric Leong

Overview

In this project, I learned how to compute the homography matrix to apply projective transforms to images and produce cool images.

Part 1: Image Warping and Mosaicing

Shooting Pictures

Here are some of the pictures I've taken so far. I've struggled a lot with finding interesting images since I have not gone outside in ages.

apple
apple
apple
apple

Recover Homographies

The homography matrix is a 3x3 matrix of the following form. We need at a minimum 4 correspondence pairs between the source and destination images to find the homography matrix because it has 8 degrees of freedom.
apple
To solve for the homography matrix, we flatten the matrix into a vector, restructure our set of correspondences into the following matrix and approximate the solution using least squares.
apple
Least squares aims to minimize this equation by finding the components of H that minimize the projective error.
apple

Once I computed the least squares solution to the above linear system of equations, I reshaped the vector back into a matrix H.

We can find the transformed pixels by computing p' as below, then dividing the first 2 elements by w.
apple

Warping and Image Rectification

Now that we've computed the homography matrix, we can use it to transform and warp images to one another. I utilize the inverse of the homography matrix to perform inverse warping, which constructs the transformed image using pixels of the original image.

Image rectification involves finding points in the original image around some object, finding the homography matrix that warps the points into a parallel shape, like a rectangle, and using the inverse homography matrix to transform the original image so that the object appears frontal parallel.

apple
Original
apple
Rectified
apple
Original
apple
Rectified