In this part, I computed the H matrix which has 8 degrees of freedom using 4 points labelled on both images. I
computed H by solving the following system of linear equations.
Stack the below 4 times for each of the 4 point correspondences:
P = [-x_i, -y_i, -1, 0, 0, 0, x_i * x'_i, y_i * x'_i, x'_i],
[0,0,0,-x_i, -y_i, -1, x_i * y'_i, y_i * y'_i, y'_i]
H = [h1, h2, h3, h4, h5, h6, h7, h8, h9]^T
PH = 0
Image Warp
I used the H matrix calculated above to do an image warp. First, I applied H on the vertices of the source image
in order to find the bounding box for the transformed image. Next, I iterated through the pixels of the
destination image and colored them based on the interpolated points from the source image.
Image Rectification
For this part, I marked the points of a rectangular image and then warped the image into a square shape.
Mosaic
Using the image warped images and some blending, I was able to get a mosaic.