In this project, we compute homography matrices and use them to rectify images as well as create mosaics using multiple photos of the same scene.
To compute the homography matrix, I find correspondance points in two images. I then use the equation p'=Hp, with p' being the points for one image and p being the corresponding points on the other, to find H.
To warp one image to another, I compute the homography matrix using their correspondance points. I find the size of the final image and create an empty image with just the image I'm warping to in the middle. I then do inverse warping for the other image by finding the locations on the new image where it will warp to and finding the corresponding points on the original.
Using the above technique, I can rectify an image by finding the corners of the object and setting its correspondance points to be the corners of the desired shape. I then find the homography matrix and warp the image to the desired shape.
Creating a mosaic of multiple images is similar to rectifying an image, with the difference being that instead of warping to a shape, I'm warping the image to another image. Now that I have both images placed appropriately, I can blend the images together to create the final mosaic.
It is pretty amazing what we can do with multiple images and a bit of math. I think it's super cool that by just computing a homography matrix I can change the perspective of images as well as stitching images with different perspectives together into one mosaic.