Colorizing the Prokudin-Gorskii Photo Collection

Kenny Chan

SID: 3040782826
CS180 Project 1

Project Overview

This project focuses on aligning and colorizing digitized glass plate photographs from the Prokudin-Gorskii collection. The original photographs were taken by Sergei Mikhailovich Prokudin-Gorskii using red, green, and blue filters, creating three separate exposures for each scene. The digitized version of these plates contains all three exposures stacked vertically in a single image.

The objective is to split these stacked images into their respective red, green, and blue channels, and then apply image processing techniques to align the plates correctly. Once aligned, the channels can be merged to produce a fully colored image with minimal artifacts.

Cathedral image
Monastery image
Tobolsk image
Examples of glass plate digitizations.

Approach

The alignment process uses Normalized Cross-Correlation (NCC) to compare how well the images match each other after applying various displacements. The blue channel is used as the reference, and the red and green channels are aligned to it by searching for the best shift in both the x and y directions.

The process is improved by using an image pyramid technique, which first aligns downscaled versions of the images to estimate the shift for the larger, original images. This approach speeds up the computation, as it reduces the number of possible displacements to be tested at higher resolutions. Specifically, each plate is progressively downscaled, and the alignment is performed on the smallest version of the image, refining the alignment as the resolution increases.

The algorithm also includes a multiprocessing feature, allowing the program to parallelize the alignment of the green and red channels, further improving speed.

Finally, an automatic cropping function is applied to remove any unnecessary borders that may affect the alignment process, ensuring a clean and focused final output image. The result is saved as a new color image, which can then be displayed and analyzed.

Results

Low-Quality Images (jpg)
Cathedral
Displacement: G (5, 2); R (12, 3)
Monastery
Displacement: G (-3, 2); R (3, 2)
Tobolsk
Displacement: G (3, 3); R (6, 3)
High-Quality Images (tiff)
Church
Displacement: G (66,0); R (60,-4)
Emir
Displacement: G (84,62); R (0,52)
Harvesters
Displacement: G (56,0); R (56,1)
Icon
Displacement: G (44,23); R (37,3)
Lady
Displacement: G (30,-16); R (30,-28)
Melons
Displacement: G (37, 0); R (59, -3)
Onion Church
Displacement: G (30,0); R (30,-1)
Sculpture
Displacement: G (30,-19); R (30,-4)
Self Portrait
Displacement: G (30,-5); R (30,-11)
Three Generations
Displacement: G (30,3); R (30,5)
Train
Displacement: G (0,-12); R (30,-3)

Bells & Whistles

Contrast

For each color channel (Red, Green, Blue), the histogram of pixel values is computed. The cumulative distribution function (CDF) of the histogram is calculated and normalized. This represents the proportion of pixels with intensities less than or equal to each value.

The np.interp function performs linear interpolation to map old pixel values to new values based on the normalized CDF. This operation adjusts the contrast by spreading pixel values over the full range. Finally, the image is scaled back to [0, 1] for consistency.

White Balance

The image is converted to a float format with values in the range [0, 1] for precision in processing. The average color of the image is calculated by taking the mean across the height and width dimensions, resulting in a vector representing the average intensity for each color channel.

A target gray point (e.g., [0.5, 0.5, 0.5]) is set. This represents the desired average color that the image should be adjusted to. Scaling factors are computed by dividing the target gray point by the average color. This determines how much each channel needs to be adjusted. The image is scaled by these factors to achieve the desired white balance. Each pixel is adjusted based on the calculated scaling factors. Pixel values are clipped to ensure they remain within the valid range [0, 1] after scaling.

Before After
Church old Church
Emir old Emir