Overview In the project, I aligned digitized RGB negatives to form a color image. These negatives are from the photo collection of Russian artist Prokudin-Gorskii, who had token pictures of every scene during the time Russian Empire.
Approach For .jpg images, I first cropped the image from shape (341, 391) to (301, 301). By cropping the image before aligning, I hope to get rid of some borders that may have large effects on my SSD score. Then I define an "align" function. I apply "align" to make red negative to blue negative, and green negative to blue negative. In align function, I shifted the red/green negative by a possible displacement pair (x, y) from all possible window. Then I calculated the Sum of Squared Differences score for this displacement pair. Then I compared all the score and picked the lowest one. The displacement pair for this score is the displacement I need. Then I just moved my red and green negatives according to their displacements and stack g, r, b channel together. For .tif images, I used pyramid align because .tif image is large. I first decided to use a pyramid with level of 5 and each level we downscale with a factor of 0.5. For example, at a certain layer X of our pyramid (the bottom layer being our original image, top being the smallest), I call my "align" function recursively to get the best displcaement for X-1 layer. Then I multiple this displacement by 2 to get new_displacement, and shift my layer X image by this new_displacement, so now my layer X is aligned based on the advice from all the layers above it. To pass the alignement information down, I added layerX's displacement by calling "align" function on only a small center of layerX image to get current_displacement. Then I add new_displacement andcurrent_displacement and pass it down to layer X+1...