Project Overview and Approach
I followed the basic algorithm of checking every offset in a 2-D window [-15, 15] and seeing which offset minimized the sum of squared differences. This worked fine for the smaller images (.jpgs) but for the .tifs the algorithm would take too long.
I implemented an image pyramid search procedure to handle larger images and I first tried to approach this algorithm by first downsizing the original image to a certain fraction of the total size (i.e. 1/8) where every downsize is a factor of 1/2. Then, I would find the offset for that small, course image level and then resize the image and offsets a level up (by resizing the image bigger by a factor of 2 and multiplying the offsets by 2). However, this resulted in loss of accuracy in offsets and shifting. The shifting of the original image also caused some discrepancies. I decided to conduct the image resizing iteratively and not in sequential order. For every factor (1/8, 1/4, 1/2, starting with the smallest), I would resize a copy of the image to that factor, find the optimal offsets for the copy at that size, scale the offsets to fit the original size image, shift the original image (not the copy) by the scaled offsets, and then restart the process with the next smallest factor.
Example Images
Offsets (g, b) = ag ==> x: 2, y: 4 Offsets (r, ag) ==> x: 2, y: 6
Offsets (g, b) = ag ==> x: 96, y: 192 Offsets (r, ag) ==> x: 162, y: 324 This image was not aligned correctly and I fixed it by aligning green (g) to blue (b) to make ag, then aligning red (r) to ag and it worked and held for all other images as well.
Offsets (g, b) = ag ==> x: 64, y: 128 Offsets (r, ag) ==> x: 58, y: 116
Offsets (g, b) = ag ==> x: 64, y: 128 Offsets (r, ag) ==> x: 90, y: 180
Offsets (g, b) = ag ==> x: 32, y: 64 Offsets (r, ag) ==> x: 40, y: 80
Offsets (g, b) = ag ==> x: 18, y: 38 Offsets (r, ag) ==> x: 6, y: 12 I had trouble with this image and it turns out it wasn't aligning properly because it was aligning with a border around the image. Once I cropped the image, the algorithm worked as it was supposed to.
Offsets (g, b) = ag ==> x: 0, y: -2 Offsets (r, ag) ==> x: 0, y: 2
Offsets (g, b) = ag ==> x: 120, y: 238 Offsets (r, ag) ==> x: 152, y: 304
Offsets (g, b) = ag ==> x: 0, y: -2 Offsets (r, ag) ==> x: 0, y: 2
Offsets (g, b) = ag ==> x: 58, y: 116 Offsets (r, ag) ==> x: 40, y: 78
Offsets (g, b) = ag ==> x: 26, y: 50 Offsets (r, ag) ==> x: 128, y: 258
Offsets (g, b) = ag ==> x: 88, y: 176 Offsets (r, ag) ==> x: 104, y: 208
Offsets (g, b) = ag ==> x: 56, y: 112 Offsets (r, ag) ==> x: 94, y: 188
Offsets (g, b) = ag ==> x: 0, y: 0 Offsets (r, ag) ==> x: 0, y: 2
Offsets (g, b) = ag ==> x: 72, y: 146 Offsets (r, ag) ==> x: 2, y: 2
Offsets (g, b) = ag ==> x: 72, y: 144 Offsets (r, ag) ==> x: 120, y: 240
Offsets (g, b) = ag ==> x: 2, y: 4 Offsets (r, ag) ==> x: 8, y: 18