CS 194-26 Project 1
Tommy Poa [acc id: aez]

Overview and approach

This project primarily focused on the alignment of the images by aligning the red and green channels to the blue channel, and was done using shortest squared difference (SSD) metric and image pyramid optimization.

The photos were first cropped by 10% on each side to focus on internal pixels. To align the photos, a specific pixel window of 16 pixels was used to calculate approriate displacement vector for the smallest/base case image. After a displacement vector is obtained through comparison using SSD, both the displacement vector and image is scaled by 2, and the process is recursively done with half the pixel window size until the original image size is yielded.

This implementation is supported by recursive functions align and pyramid_align coded.

Problems and resolution

One of the biggest problem I faced was vertical alignment. I found that cropping the images before intiating alignment helped the process and gain better vertical alignment, and this was likely due to errant pixels on the border that made the alignment inaccurate.

Optimization was also one of the problems faced as it was not fast enough. This was likely due to the fact that I was not reducing the window size after each recursive call enough, which prompted me to half them. I was also not restricting the number of recursive calls, which spurred me to add a depth field as a base case for the recursive call to restrict the maximum number of "layers" the algorithm can reach.

Example images

Images are listed together with their green and red channel offsets for alignment with blue channel. Offsets are listed in the format of [height, width].

photo

offset: [green: 5, 2] [red: 12, 3]

photo

offset: [green: -3, 2] [red: 3, 2]

photo

offset: [green: 3, 3] [red: 6, 3]

photo

offset: [green: 49, 24] [red: 103, 55]

photo

offset: [green: 59, 16] [red: 124, 13]

photo

offset: [green: 41, 17] [red: 89, 23]

photo

offset: [green: 51, 9] [red: 111, 12]

photo

offset: [green: 81, 10] [red: 155, 10]

photo

offset: [green: 51, 26] [red: 108, 36]

photo

offset: [green: 78, 21] [red: 155, 32]

photo

offset: [green: 53, 13] [red: 112, 11]

photo

offset: [green: 42, 5] [red: 87, 32]

photo

offset: [green: 64, 12] [red: 137, 22]

photo

offset: [green: 53, 0] [red: 105, -12]

Own choosing images

Images of own choosing are listed together with their green and red channel offsets for alignment with blue channel. Offsets are listed in the format of [height, width].

photo

Original

photo

offset: [green: 47, 38] [red: 107, 55]

photo

Original

photo

offset: [green: 39, -1] [red: 107, 55]

emir

Original

emir

offset: [green: 151, -6] [red: 107, 55]