Project 6: Homographies and Image Stitching

Utkarsh Singhal

Introduction

The goal of this project is to explore homographies, persepctive transforms, and image stitching. I began by shooting a bunch of pictures in and around the campus, and I picked a small subset of those for the purpose of this writeup. I manually marked the homogrpahies, used Python to compute the transform between them, and used Scipy's interp2d function to execute the transformation. Finally, I used alpha feathering to stitch the images nicely.


Recovering Homographies and Computing the transform

To recover the homogrpahies between the images, I used Python's ginput() function. This was an interative process since the first batch of homographies did not give satisfactory results, and I had to add points in the areas where the error was the highest. To compute the transform, I solved p' = Hp, where the first 8 values in H are the variables. This reduces down to system of equations that is linear in coefficients of H, and non-linear in the points p. I use least squares to solve for H, and reshape the computed vector into a 3x3 matrix.



Image rectification

This was a particularly exciting part of the project. I wandered around in Moffit and took some pictures. The next step was to demarcate the relavant homographies (corners of a rectangle to be rectified). I used a rectangle of appropriate aspect ratio as the target homography. This part required a bit of trial and error. Once that was done, I computed the H transformation matrix and applied that to the image. The results are beautiful given this simple method:


Painting (unrecitifed)
Painting (rectified)


Emergency Sign (unrectified)
Emergency Sign (recitifed)



Image stitching

As explained in intro, I computed homographies and warped the images accordingly. One thing I experimented with was different image blending strategies. Simple cut and pasting produced clear border artifacts, and after some experimentation I chose alpha feathering to combine the images. Instead of linear blending, I went with quadratic blending. Unfortunately, there are still some wedge-like artifacts in the image due to linear blending.


A house on Leconte Street
A house on Leconte Street

A house on Leconte Street


Memorial Glade
Memorial Glade

Memorial Glade


A sunny Berkeley day
A sunny Berkeley day

A sunny Berkeley day



Summary

Homographies are surprisingly powerful for how simple of a concept they are, and image recitfication was also really interesting. I noticed that the choice of homography points reallly changed the outcome of alignment process, so a good chociei of points really matters. Overall, this was a fun project.