CS194-26: Image Manipulation and Computational Photography Project 1

Images of the Russian Empire

By Alex Kassil cs194-26-aca

Part 1: Single-Scale Implementation

For the single scale implementation, I was able to align red with blue and green with blue by searching over all [-15, 15] * [-15, 15] translations, and computing the normalized cross-correlation (NCC) between the center 50 pixels. I decided to use NCC instead of sum of squared differences (SSD) due to better performance on the cathedral, and so I stuck with it for the rest of the project.

Here is my first attempt in manually aligning the monastery image

You can see that already colors start to make sense, like the green in the grass. It felt like magic when the I got this output

Cathedral

Translation: [(dxr: 12, dyr: 3), (dxg: 5, dyg: 2)] Time: .49s

I could see how useful a computer could be versus someone manually aligning the photos. The computer did it faster and the output was way better!

Then I went on to do the displacement with the rest of the .jpgs

Monastery

Translation: [(dxr: 3, dyr: 2), (dxg: -3, dyg: 2)] Time: .49s

Nativity

Translation: [(dxr: 7, dyr: 0), (dxg: 3, dyg: 1)] Time: .53s

Settlers

Translation: [(dxr: 14, dyr: -1), (dxg: 7, dyg: 0)] Time: .57s

Part 2: Image Pyramid

I had a lot of fun with this next step. Once I had the conceptual understanding down, I turned my ideas into psuedocode. My general idea was to scale down by a factor of 2 until my image was less than 200x200. From there I can do the normal translation, but only search on a [-5, 5]*[-5, 5] grid, and then scale that translation up by a factor of 2 and search within a [-1, 1]*[-1, 1] grid for the best translation to take into account the fact that I scaled down.

Before I did the image pyramid, I tried to use the single scale translation on the icon image.

Clearly the image isn't aligned

Here is an example of icon WITHOUT the [-1, 1]*[-1, 1] translation at every recursive step

Here is an example of icon WITH the [-1, 1]*[-1, 1] translation at every recursive step

It's kind of hard to see a difference between the two photos, here they are zoomed in

Here you can see how important it is to have the [-1, 1]*[-1, 1] translation between each recursive call

Here are the computed photos with translation values and time to completion. For each of these, except Emir, I am translating the red image and the green image, aligning both to blue. For Emir this didn't work, so I aligned the red and blue image to the green one.

Icon

Translation: [(dxr: 91, dyr: 23), (dxg: 43, dyg: 18)] Time: 2.73s

Harvesters

Translation: [(dxr: 125, dyr: 19), (dxg: 59, dyg: 21)] Time: 2.63s

Lady

Translation: [(dxr: 111, dyr: 11), (dxg: 50, dyg: 7)] Time: 2.70s

Self Portrait

Translation: [(dxr: 175, dyr: 37), (dxg: 77, dyg: 29)] Time: 2.82s

Three Generations

Translation: [(dxr: 111, dyr: 9), (dxg: 49, dyg: 15)] Time: 2.68s

Train

Translation: [(dxr: 85, dyr: 32), (dxg: 41, dyg: 7)] Time: 2.72s

Turkmen

Translation: [(dxr: 116, dyr: 30), (dxg: 56, dyg: 23)] Time: 2.81s

Village

Translation: [(dxr: 136, dyr: 22), (dxg: 63, dyg: 12)] Time: 2.80s

Emir

Translation: [(dxr: 58, dyr: 17), (dxb: -48, dyb: -22)] Time: 2.79s

Here was the failed Emir photo, you can see the red channel not aligning

Part 3: More photos from the Prokudin-Gorskiĭ collection

House

Translation: [(dxr: 3, dyr: 4), (dxg: 1, dyg: 2)] Time: 2.63s

Church

Translation: [(dxr: 3, dyr: 3), (dxg: 1, dyg: 3)] Time: 2.62s

Painting

Translation: [(dxr: 11, dyr: 2), (dxg: 5, dyg: 1)] Time: 2.95s

Bells and Whistles

Animation at the top of the page!

Conclusion

This project was so much fun! I especially liked using a computer to solve problems and being amazed by how quickly and correctly it cranked out beautiful photos!