Morphing

COMPSCI 194-26: Computational Photography & Computer Vision

Professors Alexei Efros & Angjoo Kanazawa

October 11th, 2021

Nick Kisel

Homography

Shooting pictures

Last weekend, I went home to Sacramento. That means I took a train and enjoyed my surroundings as I traversed the 100 mile journey. Along the way, I snapped the following photos, and made mosaics out of them:

Left train photo

The view towards the train stairwell


Right train photo

The view towards the aisle


Well, before you see the results, let's explain how this works. I selected eight corresponding points on each image I took; each of those eight points represent the location of the same objects as they change position based on the rotation of the camera.
These corresponding points allow us to compute the homography of an image, which enables the transformations required for image stitching. In reality, just four points are required for homography, but additional points provide higher accuracy if well-placed.

I used the following matrix to estimate my homography matrices:

Then, plugging in the (x, y) pairs for each of my selected points below, I calculated the most likely entries of the 3x3 homography matrix via least squares.

Left train photo annotated Right train photo annotated

Eight input points around rectangles in the train.


Right train photo annotated

A mosaic of the two extends the view using just one image. As you can see, the rightmost photo is stretched such that its points align onto the left photo's points, which allows the two photos to extend each other.


Left train photo

A view of Scenic Blvd. going eastward to campus.


Right train photo

Going westward to downtown.


Left train photo annotated Right train photo annotated

Eight input points around the sidewalk


Right train photo annotated

A mosaic of the two.


Left train photo Right train photo

Berkeley's train station with a train in-station!


Left train photo annotated Right train photo annotated

Eight input points along the train.


Right train photo annotated

A mosaic of the two.


Left train photo Right train photo

Martinez's train station from my train.


Left train photo annotated Right train photo annotated

Eight input points along the ouside of the station.


Right train photo annotated

A mosaic of the two.



Rectification

Another possible application of homography is the extraction of non-square textures from the photo's environment into a square (or other shape of your choosing). By nature of matrix transformations, the opposite can also be done to project a texture onto some object in a photo.
In this case, I grabbed the train map from the wall and the textured sidewalk.

Train poster

What's on that train poster?


Train poster

Ah, yes, very clear.


Let's feel the bumps of the pedestrian crossing.


Ah, yes, so ADA-accessible.