CS 194-26 Project 4: Image Warping and Mosaicing

Name: Suhn Hyoung Kim

Project Overview

The goal of this project is to perform image mosaicing by applying image warping techniques. We will do this through methods like homography warp images and then stitch them together to create mosaics.

Shoot and Digitize Pictures

I took 3 sets of photos to use for creating mosaics. Two sets were on my phone and I also found some photos online to stitch together. I have displayed them below.

Entrance 1
Entrance 2
Entrance 3
Room 1
Room 2
Online 1
Online 2

Recover Homographies

In order to retreive the homography matrix, I first selected correspondence points in both images that were shared using ginput. Then I built an A matrix and b vector as shown below to use least squares to retrieve a homography vector h by solving Ah = b. Then h was reconstructed in a matrix form to get the homography matrix.

A and b (source: https://towardsdatascience.com/estimating-a-homography-matrix-522c70ec4b2c)

Warp The Images

In order to warp one image into another, I first took the homography matrix calculated between the correspondence points selected for the two images. Then I figured out the potential coordinates to which the image could have been warped and shifted the image if it would end up in negative coordinates. Finally after figuring out the locations, I used cv2.remap in order to warp the image. Below I have shown the warping result for Online 1.

Warped Image Example

Image Rectification

In order to rectify images, I first selected four correspondence points matching the corners of the square or rectangle within the image that I was trying to rectify. I then selected corresponding points to transform these points to and then computed the homography matrix to make this transformation. Using this homography matrix, I then warped the original image to the rectified version.

Original Pillow
Rectified Pillow
Original Painting
Rectified Painting

Blend the Images into a Mosaic

In order to blend images into a mosaic, I created a large canvas that would be big enough to fit both images. Then I took one warped image and one of the regular images, I stitched these together by figuring out the coordinates the regular image would have to be shifted to in order to be aligned with the warped image. Then I took the max in the intersection to deside which pixels would be displayed in the mosaic. For the multiple images stitched together, I took the intermediate result between the currently stitched images and selected new points for the next homography matrix and added one more image to the final result at a time.

Online 1
Online 2
Online Images Merged
Room 1
Room 2
Room 1 and 2 Mosaic (cropped)
Entrance 1
Entrance 2
Entrance 3
Entrance 1 and 2 Mosaic (cropped)
Entrance 1 - 3 Mosaic
Entrance 1 - 3 Mosaic (cropped)

What I Learned

I found it really cool how I could use pictures that I took through my own phone cameras to generate these image mosaics and thought it was interesting to apply simpler techniques like least squares from prior classes to be able to create these visual products. However, I also learned how important it was for the photos I took to be good, which was limited by the lack of a tripod, otherwise my results wouldn't be as good.