First, the approach I took was to calculate the SSD between two matrices using numpy functions. Then I read documentation on np.roll which allows to shift the image, and found the SSD between the shifted image and another unshifted image. I then used an initial offset of -15 to 15, and interated through these offsets for both the x axis and y axis and saved the lowest result and the displacement associated with it. After getting this to work for jpg images, I then read up on what pyramid scaling was on the internet and added a recursive implementation to my original implementation. This involved rescaling the image by half, and calculating the SSD when the image hits a minimum dimension and multiplying the displacements by 2 after the recursive call. After this, I expermented with tweaking parameters such as the search space offsets and crop size of each image before alignment. In addition, I also ended up using intermediate alignment rather than aligning both green and red to blue. Instead, I aligned red to blue and then green to the newly aligned red.
I was able to align almost all of the images pretty well except self_portrait.tif. There seems to be a misalignment with the green layer as seen from the yellow misalignment in the result. I'm thinking this is a result of the image having a lot of similar shapes and colors because of the rocks, water, and plants. This causes the algorithm to find an alignment in a different place than where it should be.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|