In this project, the key idea is to align the three color channels through shifting. If we directly overlap different features, we would not be able to recover the original image accurately.
The following outlines the key algorithm we implemented:
- Similarity metric for evaluating shifts: Since each color channel may have different pixel intensities in the grayscale space, it's important to use other features to calculate similarity. In our implementation of the
align
function, we add an optionalis_edge
variable for comparison. We compare results using the edge feature against the traditional Euclidean distance as the similarity score. The results show that the edge detector significantly outperforms the traditional value-based approach (we use NCC as the similarity function), as seen in the "emir" picture.
Below: with edge 
Below: no edge detection 
-
IOU similarity: We also use IOU (Intersection over Union) similarity, which calculates the overlap between edge-detected images. This overlap method efficiently extracts image information and provides better alignment results.
-
Optimization using pyramid alignment: As suggested in the problem description, we use a pyramid alignment approach. This involves two steps:
- Generating the downsampling pyramid (using Gaussian blur with a manually implemented kernel for convolution).
- Narrowing down the results at the coarser image level before moving to higher resolutions.
In each step, we retrieve the best shift values for the x and y axes. We then adjust these values by ±1 to define the search range for the next layer. This approach, similar to binary search, allows us to efficiently find the optimal alignment.
- Ratio-based Offset Limit: To limit the search range, we assume the offset between each color channel will less than 0.05%. This works for all our available images, and this parameter is adjustable.

g shift to r: (-58, -16)
b shift to r: (-108, -40)
Train 
g shift to r: (-44, -28)
b shift to r:(-88, -34)
church.tif
g shift to r: (-34, 8)
b shift to r:(-60, 4)
harvesters.tif

g shift to r: (-64, 0)
b shift to r:(-120, -16)
icon.tif

g shift to r: (-48, -8)
b shift to r:(-90, -24)
lady.tif