Introduction:

Sergei Mikhalovic Prokudin-Gorskii, a Russian chemist and photographer, was one of the early pioneers of color photography. He popularized a method of color photography that involved aligning three differently color-filtered black-and-white-photographs. By projecting these photos through these filters, the newly colored image was synthesized. In this project, I developed code that performed this process.

Simple Displacement Calculating Algorithm:

For smaller images, a naïve algorithm could be done to analyze the best color combination. For this algorithm, the blue channel was not displaced to any extent. Specifically, the green-filtered and red-filtered images were aligned to the blue-filtered images. Both the green and red-filtered images were displaced up to 15 pixels in the negative and positive x and y direction. But how do we determine which displacement will produce the best color combination? Simply put, the Sum of Squared Differences (SSD) is utilized.

SSD Equation:

For each displacement, the Sum of Squared Differences (SSD) between the displaced images (red, green) and our base image (blue) was calculated. The amount of displacement that produced the smallest SSD was calculated. Then, the shifted red and green-filtered images were aligned with the original, blue-filtered image. The result is the colored image.

Here are the images!

sometext

Monastery G[-6, 0] R[9, 1]

sometext

Cathedral G[1, -1] R[7, -1]

sometext

Settlers G[7, 0] R[14, -1]

sometext

Nativity G[3, 1] R[7, 1]

Image Pyramid Algorithm:

Using the displacement algorithm above will take significantly longer for larger images. Complexity for this task can be significantly reduced through the image pyramid algorithm. Every pyramid needs to have a base. In an image pyramid, this will be the original image. Each level above the base will have the same photo as the level below but with a resolution decreased by a factor of 2. Levels will be added until a 400-pixel photo is collected. With the lowest resolution photo, the displacements are calculateed using the simple displacement algorithm. To calculate the optimal displacement for the level below, we assume the displacement is proprotional. The displacement is multiplied by 2 and optimized by checking if there is a better displacement within 5 units in the x and y direction. This procedure is repeated until we get our final deplacement. As you can see, some photos such as harvesters, emir, and village are extremely blurry. There could potentially be problems as edges are less defined at lower resolutions potentially resulting in blurring on the larger scale. For those reasons, edge detection was used.

Images are here

sometext

Emir G[-3, 7] R[107, 17]

sometext

Lady G[57, -6] R[7, -1]

sometext

Harvesters G[118, -3] R[120, 7]

sometext

Icon G[42, 16] R[89, 22]

sometext

Self Portrait G[50, -2] R[130, -5]

sometext

Three Generations G[52, 5] R[108, 7]

sometext

Train[41, -2] R[107, 1]

sometext

Turkmen[57, 4] R[80, 0]

sometext

Village[144, -7] R[118, -15]

Bells and Whistles: Edge Detection:

As one can see, some of the photos are slightly blurry. To fix this, the canny edge operator was pre-applied to the red, green, and blue channels. The result was then subtracted from the original channels. The same algorithms were applied. As one can see, the quality of the images improved tremendously. Because a better quality photo was found, a more optimal displacement was found. If you look at the previous pictures, you can see some blurring across the edges of people, objects, and buildings. This probably stems from strong edges in the different channels. Thus, by filtering those channels first, we make the images much clearer. Lady and Icon did not change much after the filtering. This may stem from the fact there were not as many edges/objects in those pictures.

New Alignments: Edge Detction

Monastery G[-3, 2] R[3, 2]

Cathedral G[35,2] R[12, ]

Nativity G[3, 1] R[7, 0]

Settlers G[7, 0] R[14, -1]

Emir G[49, 23] R[107, 40]

Harvesters G[60, 11] R[118, 10]

Icon G[48, 16] R[88, 22]

Lady G[58, -7] R[122, - 8]

Self Portrait G[67, 12] R[138, 22]

Train G[48, 0] R[88, 28]

Three Generations G[52, 7] R[106, 7]

Turkmen G[55, 17] R[113, 25]

Village G[67, 12] R[138, 22]

Emir

sometext

Village

sometext

Self Portrait

sometext

Harvesters

sometext

Turkmen

sometext

Bells and Whistles: Autocropping

Due to displacements, the images are unfortunately left with some unappealing borders. The standard deviations of three channels across the rows and the columns were calculated. If these standard deviations were below a threshold (0.2) they were removed. If the standard deviation was low across any of the three channels, there was low variance of pixels across that row or column. This was synonymous with there being a border because pixels across the column or row would be the same coloring. This algorithm was run within 15% from the edges of these pictures. Results can be seen below. Perhaps cropping can be improved by increasing the search window from 15% to a larger percentage.

sometext
sometext

Bells and Whistles: Auto-Contrast: Histogram Equalizing and Contrast Stretching

There are several ways to produce auto-contrasting. One of them is through a process called histogram equalizing. It is the process in which the original image is transformed by using a normalized cumalative sum. These old intensity values are mapped to new intensity values so that there is a uniform histogram of intensity values. Another process is contrast stretching. This is the process in which the range of intensity values is stretched. Because a linear scaling function is applied to the intensities, it differs from strict histogram normalization.

sometext

Settlers Contrast Stretching

sometext

Settlers Histogram Equalization