CS 194-26: Intro to Computer Vision and Computation Photography, Fall 2021

Project 1: Images of the Russian Empire: Colorizing the Prokudin-Gorskii photo collection

Ashwin Vangipuram

Overview

This project's goal is to combine the glass plate negatives from the Prokudin-Gorskii collection to reconstruct a RGB color image.

Exhaustive Search

To align the red and green channels to the blue channel, I perform an exhaustive search by trying to shift the red/green image to match the blue image. First, I shift the red/green image for every value in the range [-12, 12] in both the x and y directions. After I shift the image, I crop the outer 20% on all edges of the image to remove the border, as the border when included in the similarity metric makes the metric less accurate. Finally, I use the Sum of Squared Differences for the similarity metric, which tries to minimize the Frobenius norm of the shifted image minus the blue image. For bells and whistles, I found that just relying on the RGB pixel intensities to match when calculating similarity was not at all accurate. Instead, I extracted edge features from the images by combining a Gaussian blur and the Canny edge detector. Then, the standard exhaustive search is just run on these edge images, which only keeps the important information of the image. Examples of both methods are shown below.

Standard method using all pixels

Using only edge features

G: (2, 5), R: (3, 11)
G: (2, 5), R: (3, 11)
G: (-12, 11), R: (-12, 11)
G: (2, -3), R: (2, 3)
G: (11, 11), R: (-12, -12)
G: (3, 3), R: (3, 7)

Pyramid Search

While the exhaustive search will work for small JPG images, it will be extremeley slow for large TIF files. To speed up our computation, I implemented an image pyramid that looks at images at various resolutions. Each level up the pyramid was 1/2 as large as before, and was downsampled while accounting for anti-aliasing using the sk.transform.rescale function. We keep on downsampling till we get to an image that has less than 100 pixels, after which the standard exhaustive search from the previous part is used. Then, as we go back down the pyramid, before doing the exhaustive search, we need to multiply the previous offset by 2 to account for the downsampling. Since we are using an image pyramid and the offsets at the small resolutions get amplified later, we only need to check shifting in the range [-5, 5] in the x and y direction at all levels of the pyramid. The bells and whistles method of using the edge features to calculate similarity doesn't improve the performance as much as before, probably due to the image pyramid which allows for more fine tune shifting of the image channels. The only exception is the emir photo which is significantly better when using edge features.

Standard method using all pixels

Using only edge features

G: (28, 52), R: (40, 64)
G: (24, 49), R: (41, 107)
G: (10, 82), R: (14, 178)
G: (9, 81), R: (13, 177)
G: (3, 49), R: (11, 118)
G: (9, 54), R: (13, 111)
G: (0, 54), R: (-11, 107)
G: (-1, 53), R: (-12, 106)
G: (14, 59), R: (13, 124)
G: (18, 60), R: (14, 124)
G: (-1, 30), R: (-9, 53)
G: (4, 25), R: (-4, 58)
G: (1, 46), R: (27, 90)
G: (8, 41), R: (34, 86)
G: (9, 56), R: (7, 105)
G: (13, 52), R: (9, 110)
G: (17, 41), R: (23, 89)
G: (29, 77), R: (37, 175)
G: (21, 47), R: (31, 103)

Bells and Whistles

As mentioned earlier, since using all the pixels for similarity measurement produces incorrect shifts, especially when channels have different intensities, I instead only used the edge features of the shifted color channel when calculating the similarity metric. This was done by combining a Gaussian blur (convolution with Gaussian kernel) to remove high-frequency features and then the Canny edge detector to extract the edges from the image. The images showing the comparison are already above.

Additionally, I implemented automatic contrasting using the histogram equalization algorithm lecture. It works by first converting the RGB image to an HSV image, so we can just use the value of the pixels as the intensity. Then, we create a cumulative histogram of the all the pixel values and scale it from 0 to 1 to act as a CDF. Then we can use a fact from probability theory that applying the CDF will produce a uniform distribution over the pixel values. Some examples of the automatic contrasting are below, and it can be seen that the contrast is often extreme.

Automatic Contrasting with Histogram Equalization

Extra Images

These are more reconstructed images from the photo collection that use the edge features, but no auto-contrast.