# Report

## Approach

First, the approach I took was to calculate the SSD between two matrices using numpy functions. Then I read documentation on np.roll which allows to shift the image, and found the SSD between the shifted image and another unshifted image. I then used an initial offset of -15 to 15, and interated through these offsets for both the x axis and y axis and saved the lowest result and the displacement associated with it. After getting this to work for jpg images, I then read up on what pyramid scaling was on the internet and added a recursive implementation to my original implementation. This involved rescaling the image by half, and calculating the SSD when the image hits a minimum dimension and multiplying the displacements by 2 after the recursive call. After this, I expermented with tweaking parameters such as the search space offsets and crop size of each image before alignment. In addition, I also ended up using intermediate alignment rather than aligning both green and red to blue. Instead, I aligned red to blue and then green to the newly aligned red.

## Reflection

I was able to align almost all of the images pretty well except self_portrait.tif. There seems to be a misalignment with the green layer as seen from the yellow misalignment in the result. I'm thinking this is a result of the image having a lot of similar shapes and colors because of the rocks, water, and plants. This causes the algorithm to find an alignment in a different place than where it should be.

## Results

### Low resolution images without pyramid scaling cathedral.jpg, G(5, 2) R(12, 3) tobolsk.jpg, G(3, 3) R(6, 3) monastery.jpg, G(-3, 2) R(3, 2)

### High resolution images with pyramid scaling castle.jpg, G(32, 0) R(96, 0) emir.jpg, G(48, 24) R(104, 40) harversters.jpg, G(64, 16) R(128, 16) lady.jpg, G(56, -8) R(128, -16) melons.jpg, G(80, 0) R(176, 0) onion_church.jpg, G(56, 24) R(112, 32) self_portrait.jpg, G(88, 0) R(184, 8) three_generations.jpg, G(56, 8) R(112, 8) train.jpg, G(48, 0) R(88, 24) workshop.jpg, G(56, 0) R(104, -8) icon.jpg, G(40, 16) R(88, 24)

### Extra Images village.jpg, G(64, -8) R(136, -8) field.jpg, G(16, 8) R(48, 3) grave.jpg, G(40, 0) R(88, 8) church.jpg, G(64, 16) R(128, 24)