Before the align approaches, I first read the image and normalized them with converting to double. Then I cut the input image into 3 channels(b/g/r) using the height of each channel. I also implemented three crop functions(crop_scale, crop_to_even_pixel, crop_match) to crop the image margin/ ensure the image have even number of pixels/ make sure the 3 channels have the same sizes.
For the naive approach, I used L2 norm to compute the difference between two images, evaluated it as score, and used for loops to find the smallest score, which is the best displacement. Naive approach is ok for the jpg images, but not good for the tif images, because the tif images are really large.
To implement image pyramid, I used skimage.transform.rescale to first shrink the resolution of image channel,
then if the rescaled channel is over 300x300 resolution, I use recursive to process on a smaller image resolution,
after the recursive, I upscale the image to original resolution, also double the displacemment( for finding the
smallest score and the best displacement, I used the same L2 norm to calculate as naive approach with np.roll to
shift the channel).
Aftering align the images, I used 0.85 scale crop to cut each channel's margin off to make the output image looks better.
Other image displacement:
melons: G (2, 30) R (-8, -34)
sculpture: G (4, -64) R (52, 86)
self_portrait: G (-14, 82) R (22, -94)
train: G (-6, -88) R (0, 0)
This image downloaded from "Prokudin-Gorskii collection"
This image downloaded from "Prokudin-Gorskii collection"
For the "emir" image, I also used SSIM from skimage.metrics to make the alignment look better. The SSIM score is computed as the higher the better.
The issue in my alignment is after rescaling several times, the images go blurry, although the alignment is ok. I tried to make anti-aliasing = True or False, but the result is similiar. Since the instruction on ed says "anti-alias will blur the image before downsizing and we'll learn about this in lecture this coming week", I think it is ok for now, but I'll try to fix the blur issue after I learn more.
I found an image from pinterest website, and I used photoshop to make it into 3 RGB channels, after that, I put the image as input, and used the same image pyramid function as described above to align the channels, and then got the output image.