Project 1: Colorizing the Prokudin-Gorskii photo collection

By Adam Chang

transform.png

Overview

This project entailed consuming photos from the Prokudin-Gorskii collection and converting them from their original form of 3 separate images of the R, G, and B channels into 1 aligned RGB image.

The process I implemented to combine the three different channels into one colored RGB image is as follows:

  1. Divide the image vertically into 3 equal parts. The top image is the B channel, the middle image is the G channel, and the bottom image is the R channel.
  2. Remove the black borders at the edges of each of the 3 channel images.
  3. Run the 3 channel images through a sobel filter to extract edges.
  4. Perform multiscale pyramid alignment. Recursively downsample the image and align.
  5. Align at each recursive alignment step using sum of squared differences on the pixels of the edge extracted channel images.

Improvements

Cropping

One of the issues with the original images from the collection are a thick border of black and white at the edges of the image. This is bad on several levels. Firstly, it doesn't look good, and results in thick bands at the edges of the outputted RGB image. Secondly, it leads to worse results during the alignment phase, especially when aligning using raw pixel intensities. Since the black border is very large and inconsistent between the three channels, it can lead to weird alignments. To mitigate this issue, I wrote a simple auto-cropper that crops in the image from the edges until the black border has been reduced or completely removed. The auto-cropper works by stepping from the edges of the images, and only stopping when the row or column of the image has fewer than a predefined threshold of pure black or pure white pixels.

Below are results of cropping on cathedral.jpg:

cathedral_blue_channel_before_crop.jpg
Cathedral image blue channel before crop
cathedral_blue_channel_after_crop.jpg
Cathedral image blue channel after crop

Edge extraction

Prior to preprocessing the channel images with a sobel filter to extract edges, I was aligning the images using sum of squared differences on the raw intensity values for each channel. This lead to failures when parts of the image were dominated by regions that were primarily one color. For example, in the monastery image, the bottom dirt section is much more red than blue. This resulted in an alignment that pushed the red channel away from the blue channel, as the difference in pixel intensities in that dirt section dominated.
Image alignment using raw pixel intensities Image alignment using sobel filter Edge extracted image
monastery_aligned_with_raw_intensities.jpg
Monastery aligned using raw channel intensities.
monastery_aligned_with_edges.jpg
Monastery aligned using edges extracted with sobel filter.
monastery_edges.jpg
The edge detection image extracted using sobel filter.

White balancing

As another improvement after aligning the images, I perform white balancing using gray world theory. What this entails is taking the average intensity of all the pixels in all channels, and then normalizing each channel individually so that each channel has an average pixel intensity equal to this overall average pixel intensity. This is called the gray world theory, because it is based on the hypothesis that on average, the world is gray (cone activation in short, medium, and long cones are all equal over the entire image). The results of the white balancing are displayed to the right of each image below.

Image Results

Image Aligned Image Aligned Image White Balanced Translation from G to B Translation from R to B
Cathedral cathedral_aligned.jpg cathedral_aligned_whitebalanced.jpg 5px down, 2px right 12px down, 3px right
Church church_aligned.jpg church_aligned_whitebalanced.jpg 25px down, 3px right 58px down, 4px left
Emir emir_aligned.jpg emir_aligned_whitebalanced.jpg 49px down, 23px right 107px down, 40px right
Harvesters harvesters_aligned.jpg harvesters_aligned_whitebalanced.jpg 60px down, 18px right 123px down, 11px right
Icon icon_aligned.jpg icon_aligned_whitebalanced.jpg 42px down, 16px right 90px down, 22px right
Lady lady_aligned.jpg lady_aligned_whitebalanced.jpg 57px down, 9px right 120px down, 13px right
Melons melons_aligned.jpg melons_aligned_whitebalanced.jpg 80px down, 10px right 177px down, 13px right
Monastery monastery_aligned.jpg monastery_aligned_whitebalanced.jpg 3px up, 2px right 3px down, 2px left
Mosque mosque_aligned.jpg mosque_aligned_whitebalanced.jpg 3px down, 0px right 8px down, 1px right
Onion Church onion_church_aligned.jpg onion_church_aligned_whitebalanced.jpg 52px down, 25px right 108px down, 35px right
Self Portrait self_portrait_aligned.jpg self_portrait_aligned_whitebalanced.jpg 78px down, 29px right 176px down, 37px right
Three Generations three_generations_aligned.jpg three_generations_aligned_whitebalanced.jpg 56px down, 12px right 112px down, 8px right
Tobolsk tobolsk_aligned.jpg tobolsk_aligned_whitebalanced.jpg 3px down, 2px right 7px down, 3px right
Train train_aligned.jpg train_aligned_whitebalanced.jpg 41px down, 0px right 85px down, 29px right
Trees trees_aligned.jpg trees_aligned_whitebalanced.jpg 3px up, 1px right 4px up, 1px right
Workshop workshop_aligned.jpg workshop_aligned_whitebalanced.jpg 52px down, 1px left 102px down, 12px left