Russian Empire Images:
Colorizing the Prokudin-Gorskii photo collection

Overview

This project aimed to automatically produce color images from Sergei Mikhailovich Prokudin-Gorskii's digitized glass plate negatives. These negatives contain three separate exposures taken through red, green, and blue filters, capturing the Russian Empire in the early 20th century. Our goal was to align these exposures and combine them into a single color image with minimal visual artifacts.

Approach

Small images: Exhaustive search

For small images, I implemented an exhaustive search algorithm using the euclidean distance (L2 norm) as the error metric. This approach involved shifting the green and red channels over a range of possible offsets relative to the blue channel, which remained fixed. For each offset, the L2 distance between the overlapping regions was calculated. The offset that yielded the minimum error was selected as the best alignment.

While effective for small images, this method had limitations. The computational cost increased significantly with larger search ranges, making it impractical for bigger images or when a wider range of potential offsets needed to be considered. Despite these constraints, the exhaustive search proved to be robust and accurate for aligning the color channels in smaller images from the Prokudin-Gorskii collection, producing visually pleasing results with minimal artifacts.

Large images: Gaussian Pyramids with edge detection

For the larger images, I utilised a Gaussian pyramid approach in conjunction with edge detection.

I created a Gaussian pyramid by recursively applying a Gaussian filter to the image and downsampling it. We then calculate the best shift at the top level of the pyramid, and use this as a base for the next layer. By repeating this at every layer until we get to our original image we do not have to calculate as big of a window at any single level.

Takeaways

I think my techniques worked quite well. The only image that I think could be aligned better is the "lady" image. Which I believe is because of its blurry edges. I would like to improve the white balance because as you can see in the full list of examples, some images it improves, some it makes unnaturally dark.

Bells and Whistles

Edge Detection

To improve alignment accuracy on bigger images I applied a sobel kernel to the image to get isolate the edges in the x and y direction. This improves the accuracy of the alignment as the edges, rather than all the pixels in the image.

original guy image

Original Image

Shift: Green: (41, 9), Red: (35, -291)

Church after Sobel kernel convolution

Image after Sobel kernel convolution

Gaussian Pyramid without edge detection

Final image Gaussian Pyramid with edge detection

Shift: Green: (49, 23), Red: (107, 40)

Localized Histogram Equalisation

Process: I got the histogram for each of the 3 channels of the image, and then applied histogram equalization by mapping the cumulative distribution function (CDF) of the histogram to the pixel values. This was done for each of the 3 channels.


I then performed this technique in localized regions across the image to avoid darkening or lightening the image too much overall.

As you can see the added contrast makes detail in the image more visible, in the global histogram equalisation, and even more so with the localized histogram equalisation. You can also see that the global histogram equalisation makes the image look unnatural.

original church image

Before Histogram Equalisation

Church after Sobel kernel convolution

Image after GLOBAL Histogram Equalisation

Gaussian Pyramid without edge detection

Image after LOCALIZED Histogram Equalisation

Automatic White Balance

Process: I first calculated the illumant using the average pixel value of the aligned image. Next, I computed scaling factors for each color channel (R, G, B) that would shift the estimated illuminant towards pure white (equal values in all channels). These scaling factors were then applied to the entire image, effectively removing the color cast. To preserve the overall brightness of the image, we normalized the scaling factors to ensure that the brightest channel remained unchanged.

Church after white balance

Before white balance

Gaussian Pyramid without edge detection

After white balance

Gaussian Pyramid without edge detection

The illuminant

Final Thoughts

Over the summer I learned how to edit photos using software like Adobe Lightroom. This project was particularly interesting to me because I got to see how a lot of their features are implemented in code.

The next things that I would like to implement are automatic cropping (so we can avoid the chromatic aberration at the edges of the image) and color grading tools for personalizing the image.

Images

Cathedral

Cathedral Pre-Histogram

Edge Gaussian Pyramid Aligned image

Cathedral Output

Now with histogram equalisation and white balance

Shift: Green: (5, 2), Red: (12, 3)

Church

Church Pre-Histogram

Edge Gaussian Pyramid Aligned image

Church Output

Now with histogram equalisation and white balance

Shift: Green: (25, -2), Red: (61, -14)

Emir

Emir Pre-Histogram

Edge Gaussian Pyramid Aligned image

Emir Output

Now with histogram equalisation and white balance

Shift: Green: (49, 23), Red: (107, 40)

Harvesters

Harvesters Pre-Histogram

Edge Gaussian Pyramid Aligned image

Harvesters Output

Now with histogram equalisation and white balance

Shift: Green: (60, 17), Red: (129, 3)

Icon

Icon Pre-Histogram

Edge Gaussian Pyramid Aligned image

Icon Output

Now with histogram equalisation and white balance

Shift: Green: (40, 16), Red: (90, 23)

Lady

Lady Pre-Histogram

Edge Gaussian Pyramid Aligned image

Lady Output

Now with histogram equalisation and white balance

Shift: Green: (58, -10), Red: (125, -21)

Melons

Melons Pre-Histogram

Edge Gaussian Pyramid Aligned image

Melons Output

Now with histogram equalisation and white balance

Shift: Green: (78, 5), Red: (177, 11)

Monastery

Monastery Pre-Histogram

Edge Gaussian Pyramid Aligned image

Monastery Output

Now with histogram equalisation and white balance

Shift: Green: (-3, 2), Red: (3, 2)

Onion Church

Onion Church Pre-Histogram

Edge Gaussian Pyramid Aligned image

Onion Church Output

Now with histogram equalisation and white balance

Shift: Green: (52, 24), Red: (107, 35)

Sculpture

Sculpture Pre-Histogram

Edge Gaussian Pyramid Aligned image

Sculpture Output

Now with histogram equalisation and white balance

Shift: Green: (33, -11), Red: (140, -26)

Self Portrait

Self Portrait Pre-Histogram

Edge Gaussian Pyramid Aligned image

Self Portrait Output

Now with histogram equalisation and white balance

Shift: Green: (78, 29), Red: (176, 37)

Three Generations

Three Generations Pre-Histogram

Edge Gaussian Pyramid Aligned image

Three Generations Output

Now with histogram equalisation and white balance

Shift: Green: (54, 0), Red: (111, 7)

Tobolsk

Tobolsk Pre-Histogram

Edge Gaussian Pyramid Aligned image

Tobolsk Output

Now with histogram equalisation and white balance

Shift: Green: (3, 3), Red: (6, 3)

Train

Train Pre-Histogram

Edge Gaussian Pyramid Aligned image

Train Output

Now with histogram equalisation and white balance

Shift: Green: (41, 1), Red: (85, 29)

Other Images

Plants

Plants Pre-Histogram

Edge Gaussian Pyramid Aligned image

Plants Output

Now with histogram equalisation and white balance

Shift: Green: (42, -38), Red: (108, -82)

Flower Bush

Flower Bush Pre-Histogram

Edge Gaussian Pyramid Aligned image

Flower Bush Output

Now with histogram equalisation and white balance

Shift: Green: (48, -8), Red: (96, -24)

Garden

Garden Pre-Histogram

Edge Gaussian Pyramid Aligned image

Garden Output

Now with histogram equalisation and white balance

Shift: Green: (59, 27), Red: (126, 34)