In this project, I aimed to create three different mosaics: a mosaic of the view from my apartment, a mosaic of my room, and a mosaic of a spot on campus. To create each of these mosaics, I took two to three photographs of the scene from the same point of view but with different view directions and with overlapping fields of view. Here are the sets of pictures that I obtained:
I computed the Homography matrix for each mosaic by first defining point correspondences between each pair of images in the mosaic. My criteria for choosing correspondence points was to find corners shared between the two images, for example, the windowsil on a building, the corner of a desk, etc. Here are the correspondences:
Given the point correspondences, I calculated the Homography matrix H between each pair of images in the mosaic using least squares to solve for the eight unknown entires of the matrix. The correspondence points are represented by p and p', where p are the source points and p' are the target points to which the source points should be warped to. Below is my derivation for finding h, the matrix that contains the 8 unknown entries of the Homography matrix. By obtaining the entries of the homography matrix and solving for h, I was able to find the transformation matrix H between each pair of images in the mosaic:
Next, I attempted to warp the images according to the homography matrix calculated. I defined a method called warpImage that would do the warping: it takes in both the image to be warped as well as the homography matrix and
warps the input image correspondingly to the transformation matrix passed in.
Before warping the images of my mosaic, I tested my warpImage method on some planar surfaces, such as a painting on a wall in a museum and a painting on a cieling, and warped them so that the planes were frontal-parallel. Below are my results of warping these paintings such that they became frontal-parallel:
Finally, I tackled creating my mosaics. First I warped the individual pictures of the mosaic using the calculated Homography matrix and displaced the warped images on the canvas such that there was room for me to stitch together the rest of the mosaic adjacent to it. Then, I created an alpha blending mask in order to blend together the two parts of the mosaic. To create a smooth blend, I created the mask such that its values would gradually decrease to 0 with increasing values of x. This process and the resulting mosaics are displayed below:
Overall, I had a lot of fun working on this project, as I learned how to create my own panoramic images from scratch! One of the coolest aspects of this project was the fact that we implemented open cv's warp perspective method on our own by calculating the projective warping transformation matrix using least squares. I also thought that it was super interesting how we applied concepts in previous projects, such as alpha channel blending, in order to create our mosaics. I learned that many concepts in computer vision translate over in a variety of different contexts and applications.