Naive Single-Scale: Small Images
- Max normalized cross-correlation (over min Euclidean distance)
- 3.2326s on average
For implementing the naive single-scale search, I used the max normalized cross-correlation to find the best offset between the green (G) and red (R) channels to align to the blue (B) channel.
Given that this algorithm is computationally expensive and uses exhaustive search, the naive single-scale algorithm is used for smaller JPG images.
I initially tried to find the most optimal (dx, dy)
displacement by finding the minimum Euclidean distance between the two channels that are being compared.
The Euclidean distance, aka the L2 norm, has the following form:
L2(image1, image2) = sqrt(sum(sum((image1-image2).^2)))
This, however, kept on giving me artifacts in the output images, so I decided to use the max normalized cross-correlation instead.
The max normalized cross-correlation, aka the NCC, has the following form (the dot product of the normalized vector representation of the images):
NCC(image1, image2) = (image1/||image1||) · (image2/||image2||)
In summary, I found the most optimal
(dx, dy)
displacement by finding the maximum value of the NCC between the two channels that are being compared, after realizing that finding the minimum L2 distance was not as effective (for some reason).
monastery.jpg
Middle (G) offset: (2, -3)Bottom (R) offset: (2, 3)
Input: ../data/monastery.jpg
Alignment function: naive_ss
Show image: True
Middle (G) offset: (2, -3)
Bottom (R) offset: (2, 3)
Output: ../images/naive_ss_monastery.jpg
Time taken: 3.0769 seconds.
tobolsk.jpg
Middle (G) offset: (3, 3)Bottom (R) offset: (3, 6)
Input: ../data/tobolsk.jpg
Alignment function: naive_ss
Show image: True
Middle (G) offset: (3, 3)
Bottom (R) offset: (3, 6)
Output: ../images/naive_ss_tobolsk.jpg
Time taken: 3.2929 seconds.
cathedral.jpg
Middle (G) offset: (2, 5)Bottom (R) offset: (3, 12)
Input: ../data/cathedral.jpg
Alignment function: naive_ss
Show image: True
Middle (G) offset: (2, 5)
Bottom (R) offset: (3, 12)
Output: ../images/naive_ss_cathedral.jpg
Time taken: 3.3281 seconds.