Project Overview

In this project we needed to overlay 3 black and white negatives in order ot produce a single full color RGB image.
Splitting this trifold of black and white negatives isn't perfect, however. We need to create an algorithm to align them so they look right once overlayed.

Naive Approach: Window Search

We choose one channel to remain stationary. For the other two channels, we try shifting the 2D matrix through a specified window for its x and y coordinates. At each x and y coordinate shift, we calculate the normalized cross correlation value. The highest NCC value will dictate which shift is best for the channel. Note: When calculating NCCs, we crop all the images by 10% on each side to make it less likely that we're comparing borders instead of the actual image.

More Efficient Approach: Image Pyramid

For large enough images, this search becomes too expensive. We now implement an image pyramid where the window search is only performed once the image is sufficiently small, achieved by recursively scaling down the image by half until a specified image size is reached. This shift is then propagated and scaled up to give us the shift we need on our original, large pixel-ed image.

Results - Example Images

All images use blue for the base channel.
An offset (x,y) means the origin of the channel was shifted (and excess pixels rolled) x pixels down, y pixels right

Image: Cathedral
Offsets: Green (5,2) Red (12,3)

Cathedral-colorized

Image: Emir
Offsets: Green (48,32) Red (96,-208)

Emir-colorized

Image: Harvesters
Offsets: Green (64,16) Red (128,16)

Harvesters-colorized

Image: Icon
Offsets: Green (48,16) Red (96,16)

Icon-colorized

Image: Lady
Offsets: Green (48,16) Red (112,16)

Lady-colorized

Image: Monastery
Offsets: Green (-3,2) Red (3,2)

Monastery-colorized

Image: Nativity
Offsets: Green (3,1) Red (7,0)

Nativity-colorized

Image: Self-Portrait
Offsets: Green (80,32) Red (176,32)

Self-Portrait-colorized

Image: Settlers
Offsets: Green (7,0) Red (14,-1)

Settlers-colorized

Image: Three Generations
Offsets: Green (48,16) Red (112,16)

Three_generations-colorized

Image: Train
Offsets: Green (48,0) Red (96,32)

Train-colorized

Image: Turkment
Offsets: Green (48,16) Red (112,32)

Turkmen-colorized

Image: Village
Offsets: Green (64,16) Red (128,16)

Village-colorized

Results - Novel Images

Image: Bridge Over River
Offsets: Green (32,0) Red (144,0)

Bridge_over_river-colorized

Image: Piony
Offsets: Green (48,0) Red (112,0)

Piony-colorized

Image: Lugano
Offsets: Green (48,0) Red (112,32)

Lugano-colorized

Alignment Challenges

Emir alignment didn't turn out very good. My guess is that the blue channel values were very high, and the red channel values very low, so all alignments had bad NCC scores and the optimal alignment was indistinguishable from the worse alignments.