Homework 1 

Overview:

For this assignment, I generally followed the details given by the assignment, using the python starter code as the base for the project. Ultimately I tried both the sum of squared differences and the normalized cross corellation, before settling on the normalized cross corellation to take advantage of the large amount of matrix math it could us. This allowed me to take advantage of the speedy implementations in the Numpy library.

After I had the alignment procedure implemented, I added a window of search and comparison procedure, to find the best aligned image. I would then return the x and y co-ordinates, roll the images by that amount, and then stacked and saved them. This worked quite well on the small images.

For the large images (above a certain size threshold), I implemented a basic image pyramid, reducing the image down to 1/32 size and running my alignment function on the small image with a large search window. I would then multiply those coordinates by 2, and run the alignment based from those coordinates on a small window on the image with twice the scale. This continues until the image is at its largest size, and the final offset values are returned.

The above strategies worked for around two-thirds of the images, but was unsatisfactory on the y-offset values it found. I decided to crop the horizontal and vertical borders that were causing misalignment along the edges of the images rather than the pixels in them. After this, all but the emir.tif image were satisfactorily aligned.

For the emir image, I believe a more sophisticated algorithm would have solved many of my problems, such as detecting edges or focusing on the center of the image more through applying some sort of mask to diminish the edge importance.

Images
"**" denotes images I have added to the project
All output images can be found in the output folder


workshop.tif:

green channel y offset: -76 green channel x offset: -1
red channel y offset: -157 red channel x offset: -13


emir.tif:

green channel y offset: -79 green channel x offset: 24
red channel y offset: -125 red channel x offset: 39


monastery.jpg:

green channel y offset: -16 green channel x offset: 2
red channel y offset: -23 red channel x offset: 2


three_generations.tif:

green channel y offset: -75 green channel x offset: 9
red channel y offset: -143 red channel x offset: 10


melons.tif:

green channel y offset: -46 green channel x offset: 4
red channel y offset: -78 red channel x offset: 8


**flowers.tif**:

green channel y offset: -80 green channel x offset: -6
red channel y offset: -164 red channel x offset: -25


onion_church.tif:

green channel y offset: -77 green channel x offset: 26
red channel y offset: -150 red channel x offset: 36


train.tif:

green channel y offset: -87 green channel x offset: 1
red channel y offset: -170 red channel x offset: 30


tobolsk.jpg:

green channel y offset: -10 green channel x offset: 2
red channel y offset: -20 red channel x offset: 3


icon.tif:

green channel y offset: -89 green channel x offset: 17
red channel y offset: -170 red channel x offset: 23


cathedral.jpg:

green channel y offset: -8 green channel x offset: 2
red channel y offset: -14 red channel x offset: 3


village.tif:

green channel y offset: -66 green channel x offset: 0
red channel y offset: -119 red channel x offset: 0


**tree.tif**:

green channel y offset: -53 green channel x offset: -41
red channel y offset: -142 red channel x offset: -68


**lake.tif**:

green channel y offset: -90 green channel x offset: -2
red channel y offset: -109 red channel x offset: -7


self_portrait.tif:

green channel y offset: -67 green channel x offset: -2
red channel y offset: -88 red channel x offset: -3


harvesters.tif:

green channel y offset: -68 green channel x offset: 15
red channel y offset: -131 red channel x offset: 13


lady.tif:

green channel y offset: -70 green channel x offset: 0
red channel y offset: -156 red channel x offset: -9

Analysis:

All of the images aligned fairly well, with the exception of emir.tif and lady.tif. The reason for emir not aligning, is that the high contrast areas of the images do not align with eachother, causing the algorithm to believe the true alignment is not a good alignment. The lady image has a lot of repetition of pattern on her blouse and hair, which could be leading the algorithm to align to the wrong parts of the image. In fact, the dress seems fairly aligned but the hair clearly isn't, indicating that the image may be aligned to the incorrect portion