In this project, I used the sum of squared differences (SSD) distance to align and subsequently colorize the digitized glass plate images from the Prokudin-Gorskii photo collection. The starter code conveniently already extracts the three color channel images for me, but it was my job to implement the aligning process. There is a basic aligning function well suited for smaller images (like in .jpg format) and there is a pyramid aligning function that is better suited for larger images.
My code uses a simple nested for loop to find the smallest SSD distance between two image matrices over a [-10, 10] pixel range. Initially, I was having difficulty finding the correct offsets, so I crop a 1/16th off of each side of the images before aligning which eliminates noisy input from the dark borders of the images.
|
|
|
Pyramid alignment is the process of taking the input image and first finding the correct offset on a much smaller version of the image, so as to narrow down the search space for later iterations. This algorithm is better suited for bigger images so that the overall search time is shorter. The algorithm continually resizes the image larger (usually by a factor of 2) until it reaches the original size. In my code, I resize the image five times, by a factor of 2 each time. The first iteration searches a range of [-10, 10] from the initial displacement of 0 and each iteration thereafter searches a range of [-2, 2] from the previous iteration's scaled-up displacement. The reason behind searching this range [-10, 10] for the first image was trial and error. Originally, I had a smaller range of [-5, 5] which worked well for some images like "Emir" but I found that I needed to increase the range in order to align images like "Self Portrait" correctly.
|
|
|
|
|
|
|
|
|
|
|
I also implemented intermediate alignment in the pyramid alignment algorithm, where I first align the green channel with blue, then align the red channel using the new aligned green matrix. This allowed me to correctly align the red channel on "Emir" and also improved the alignment on other images.
|
|
I downloaded and ran my image processing code on more photos from the collection.
|
|
|
|