Project 1

Aligning blue, green, and red images to create a color photo from the Prokudin-Gorskii collection


I started of the project with a single-scale implementation. I used np.roll to shift the image a few pixels at a time. At each iteration I compared the two images with NCC (Normalize Cross Correlation) and checked if the current alignment was better than the previous ones.


I then implemented a multi-scale version where I scaled the images down by a factor of 2 in a type of pyramid. I then compared the images at the lowest scale and then scaled them up and compared them again. This way I could find the best alignment at a lower scale and then refine it at a higher scale to save computation time.


This worked for all the images we were given except the one of emir. For that image I had to implement a different comparison algorithm. What I did was to create a copy of each image that was rolled to the right by 1 pixel. I then calculated the difference between the original image and the right-shifted image to have a new image describing where to find edges and surfaces in the image. Afterwards, I compared the difference-image of the blue image with the difference-image of the green image and red difference-images with NCC to find the best alignment.


The parameters I used were a max-search of 15 pixels in each direction. I also cut the images to only include the center 50% of the image when computing NCC to make it both faster and more accurate due to the noise near the borders of the images. To make the computation faster I also made the function roll the images 3 pixels at a time until the last iteration where I only rolled them 1 pixel at a time with a max-search of 3 pixels.

Results

Cathedral

Cathedral

Green Offset: (5, 2)

Red Offset: (12, 3)

Church

Church

Green Offset: (25, 4)

Red Offset: (58, -4)

Harvesters

Harvesters

Green Offset: (59, 17)

Red Offset: (123, 14)

Icon

Icon

Green Offset: (41, 17)

Red Offset: (89, 23)

Lady

Lady

Green Offset: (52, 8)

Red Offset: (110, 12)

Melons

Melons

Green Offset: (82, 11)

Red Offset: (170, 11)

Monastery

Monastery

Green Offset: (-3, 2)

Red Offset: (2, 2)

Onion Church

Onion Church

Green Offset: (50, 27)

Red Offset: (108, 37)

Sculpture

Sculpture

Green Offset: (33, -11)

Red Offset: (140, -27)

Self Portrait

Self Portrait

Green Offset: (78, 29)

Red Offset: (170, 36)

Three Generations

Three Generations

Green Offset: (50, 14)

Red Offset: (110, 12)

Tobolsk

Tobolsk

Green Offset: (3, 3)

Red Offset: (7, 3)

Train

Train

Green Offset: (42, 6)

Red Offset: (86, 32)

Emir

Emir

Offset: (49, 17)

Offset: (107, 37)




Bottom note: I had a lot of fun with this project! I am still not enrolled in the course, but I hope that my effort in the first project will give me a chance to take the course. I am looking forward to the next projects!