The project involves the task of creating color images from three different images containing the red, green and blue. The initial approach involves searching over a window of displacements (the pictures below use (-15, 15)) and chooses the displacement with the minimum value of an error metric (the pictures below use the sum of square difference metric).
While this approach works well for smaller images like the ones shown below, the number of displacements to search for becomes computionally expensive as the size of the image increases.
In order to align the bigger TIF images in a reasonable amount of time, a recursive implementation of the image pyramid algorithm was used. This involved scaling down the image until it is less than 300x300 in size. At this point, the exhaustive search is used to come up with a displacement on the smaller images. Then, the channel is displaced by the displacement in the higher resolution image to figure out an offset on the higher resolution image.
In order to crop the borders from the above images, a heuristic was used that checks the normalized value on the 3rd dimensions and if it is more than 0.88 or less than 0.12, it marks the pixel. If the number of marked pixels in a row or column is 85% or more than its length, the row/column is pruned. This method stops iterating as soon as the first row/column fails the test (to only crop the borders).
This check fails for the following image because the sky is almost white and blends with the border, thus thinking of it as a border and pruning it.
In order to fix the first picture above, instead of using the L2 norm on the RGB values, the picture was first passed through a Canny filter with the minimum and maximum threshold of 50 and 100 respectively. The filtered image with edges enhanced is used to align the images.