CS180 Project 1

Project Overview: This project involves aligning color channels from digitized Prokudin-Gorskii glass plate images to create full-color photographs. Prokudin-Gorskii used a unique method of capturing three exposures of every scene using red, green, and blue filters. Our task was to automatically align these channels using image processing techniques to produce coherent color images, with the aim of preserving historical moments from the early 20th-century Russian Empire.

Part 1

Approach: For Part 1, a straightforward exhaustive search was implemented to align the red and green channels to the blue channel by calculating the L2 norm or Normalized Cross-Correlation (NCC) between cropped regions of the images. This method worked well for low-resolution images but struggled with higher-resolution ones due to computational expense and limited search ranges. The results below show the aligned images along with their calculated offsets. A major challenge in this project was accurately aligning the color channels, particularly for high-resolution images. I initially used the L2 norm for alignment, but it didn't handle brightness differences well between channels, so I switched to Normalized Cross-Correlation (NCC) for better performance. However, implementing NCC proved frustrating; after hours of debugging and verifying my approach, I still couldn't resolve alignment issues. In the end, I rewrote the alignment code from scratch, and it worked correctly on the first try. I suspect the original problems stemmed from subtle errors in the distance calculations or misapplication of the NCC metric.

Cathedral
Cathedral
R Offset: [5, 2], G Offset: [12, 3]
Monastery
Monastery
R Offset: [-3, 2], G Offset: [3, 2]
Tobolsk
Tobolsk
R Offset: [3, 3], G Offset: [6, 3]

Part 2

Approach: For Part 2, an image pyramid algorithm was employed to efficiently handle high-resolution images by recursively downscaling each image until a manageable size was reached. A smaller search window was used on the downscaled image, and the resulting alignment was scaled up for refinement at higher resolutions. This method significantly improved alignment accuracy and reduced computation time. Below are the results of the aligned images using the image pyramid approach, along with their offsets. I tested both NCC and L2 norm as alignment metrics to determine which worked best, and found that NCC consistently provided better results, especially for images with significant brightness variations. Having spent so much time debugging in the previous part, I was meticulous in this implementation. The only mistake I encountered was forgetting to rescale the displacement correctly when moving up the image pyramid. Fortunately, I identified and fixed this within about 15 minutes, leading to successful alignments with minimal additional troubleshooting. Also, for Emir, I was unable to align it with both NCC and L2, I suspect this is due to the unique brightness level of the image meaning that a different distance function would be required.

Church
Church
R Offset: [25, 4], G Offset: [58, -4]
Emir
Emir
R Offset: [49, 24], G Offset: [112, -1050]
Harvesters
Harvesters
R Offset: [60, 17], G Offset: [124, 14]
Icon
Icon
R Offset: [41, 17], G Offset: [90, 23]
Lady
Lady
R Offset: [52, 9], G Offset: [112, 12]
Melons
Melons
R Offset: [82, 10], G Offset: [178, 13]
Monastery
Monastery
R Offset: [-3, 2], G Offset: [3, 2]
Onion Church
Onion Church
R Offset: [52, 26], G Offset: [108, 36]
Sculpture
Sculpture
R Offset: [33, -11], G Offset: [140, -27]
Self Portrait
Self Portrait
R Offset: [79, 29], G Offset: [176, 37]
Three Generations
Three Generations
R Offset: [53, 14], G Offset: [112, 11]
Tobolsk
Tobolsk
R Offset: [3, 3], G Offset: [6, 3]
Train
Train
R Offset: [42, 6], G Offset: [87, 32]
Cathedral
Cathedral
R Offset: [5, 2], G Offset: [12, 3]

Examples

Additional Examples: Below are some examples of additional images aligned using the same pyramid-based NCC approach.

Man with Camel
Man with Camel
R Offset: [20, 15], G Offset: [80, 38]
Napoleon
Napoleon
R Offset: [63, 5], G Offset: [133, -2]
Zakat
Zakat
R Offset: [75, -41], G Offset: [114, -68]