# Project 6A: Image Warping and Mosaicing

CS196-24 FA18 // David Xiong (cs194-26-abr)

## Project Overview

In this project, we use image warping via homographies to generate a panorama from a sequence of images.

This part contains the first half of the project: homeographies, image warping and rectification, and image mosaicing.

## Part 1: Recovering Homeographies

In order to warp images, we must first recover the parameters of the transformation between each pair of images. By limiting the movement of our camera to rotation we are able to generate different perspectives of a single subject - we can then defiine correspondance points, and warp between them accordingly.

The equation $$p' = Hp$$ represents the mapping between two points that share the same center of projection. We can use the homography matrix $$H$$ to warp points $$p$$ to the transformed set of points $$p'$$.

Let's define $$H$$ as a 3x3 matrix with 8 unknown values (we can set the bottom-right to always be 1 for ease-of-use). We can use a linear system with 8 unknown variables to solve for these values - we can set them up as shown below and use least-squares to solve for $$h$$

$$\begin{bmatrix} x_1 & y_1 & 1 & 0 & 0 & 0 & -x_1'x_1 & -x_1'y_1 \\ 0 & 0 & 0 & x_1 & y_1 & 1 & -y_1'x_1 & -y_1'y_1 \\ x_2 & y_2 & 1 & 0 & 0 & 0 & -x_2'x_2 & -x_2'y_2 \\ 0 & 0 & 0 & x_2 & y_2 & 1 & -y_2'x_2 & -y_2'y_2 \\ x_3 & y_3 & 1 & 0 & 0 & 0 & -x_3'x_3 & -x_3'y_3 \\ 0 & 0 & 0 & x_3 & y_3 & 1 & -y_3'x_3 & -y_3'y_3 \\ x_4 & y_4 & 1 & 0 & 0 & 0 & -x_4'x_4 & -x_4'y_4 \\ 0 & 0 & 0 & x_4 & y_4 & 1 & -y_4'x_4 & -y_4'y_4 \end{bmatrix} \begin{bmatrix} h_1 \\ h_2 \\ h_3 \\ h_4 \\ h_5 \\ h_6 \\ h_7 \\ h_8 \end{bmatrix} = \begin{bmatrix} x'_1 \\ y'_1 \\ x'_2 \\ y'_2 \\ x'_3 \\ y'_3 \\ x'_4 \\ y'_4 \\ \end{bmatrix}$$

$$H = \begin{bmatrix} h_1 & h_2 & h_3 \\ h_4 & h_5 & h_6 \\ h_7 & h_8 & 1 \end{bmatrix}$$

## Part 2: Image Rectification

The Enchanted Domain, IX, 1953 (Magritte) exhibit at SF MOMA

Outdoor screen at BAMPFA

## Part 3: Image Mosaicing

The ASUC Amazon Center

A manor scene from Elder Scrolls Online

Some Magic: The Gathering cards. I'm impressed at how readable the overlapped text is!

## Conclusion

This project has been really cool so far, it's been really great to see how simple the concept of homeography matrices are and how they can be used to map points on an image for warping. The application of this warping to make panoramas was interesting too; by defining points of correspondance we can warp one image to fit the perspective of another, and generate a panorama by blending the two together. Defining correspondences was quite important though - through trial and error I learned that it was often easier to define correspondence points in complex scenes with well-defined features, and that the further apart the points of correspondence were the more likely the overlapping features would actually line up. Part 2 of this project deals with automatic feature selection, so I'm looking forward to learning about that!