Project 1!

Approach 1: Naive Approach

I used a naive approach that loops over possible (x,y) displacements from -15 to 15 in each axis. The displacements were performed by using np.roll. I tried this approach using 3 different losses. L2 loss and normalized cross correlation were recommended by the assignment, but I got the best results using structural similarity, which I found worked well for projects in past years. For cathedral.jpg using negative structural similarity as my loss, the optimal displacements found were Green Displacement = 5, 2 and Red Displacement = 12, 3.

L2 Loss

Cathedral aligned using l2 loss

Negative Normalized Cross-Correlation (NCC)

Cathedral aligned using ncc loss

Negative Structural Similarity Loss

Cathedral aligned using ss loss

Approach 2: Pyramid Approach

I used a recursive implementation to execute the pyramid approach and optimize the search process. At each call, the recursive function will call itself on the image downsized by 1/2. This returns the optimal displacement for the downsized image (x, y). Then we rescale this to 2x and 2y and search for the optimal displacement in a x-10 to x+10 and y-10 to y+10 window.

Emir

emir.tif Green Displacement = 50, 21
emir.tif Red Displacement = 105, 40

Church

church.tif Green Displacement = 25, 4
church.tif Red Displacement = 58, -4

Harvesters

harvesters.tif Green Displacement = 59, 14
harvesters.tif Red Displacement = 122, 11

Icon

icon.tif Green Displacement = 39, 16
icon.tif Red Displacement = 89, 23

Lady

lady.tif Green Displacement = 57, 8
lady.tif Red Displacement = 120, 12

Melons

melons.tif Green Displacement = 88, 10
melons.tif Red Displacement = 178, 12

Monastery

monastery.jpg Green Displacement = -3, 2
monastery.jpg Red Displacement = 3, 2

Onion Church

onion_church.tif Green Displacement = 52, 23
onion_church.tif Red Displacement = 108, 35

Self Portrait

self_portrait.tif Green Displacement = 78, 28
self_portrait.tif Red Displacement = 175, 36

Tobolsk

tobolsk.jpg Green Displacement = 3, 2
tobolsk.jpg Red Displacement = 6, 3

Train

train.tif Green Displacement = 41, 1
train.tif Red Displacement = 85, 29

Three Generations

three_generations.tif Green Displacement = 57, 15
three_generations.tif Red Displacement = 112, 9

Sculpture

sculpture.tif Green Displacement = 33, -11
sculpture.tif Red Displacement = 140, -27

Bells and Whistles

I noticed that on some images, particularly on melons.tif, some parts of the image were very dark and lacked contrast. I applied automatic contrasting that rescales the pixel values of each channel to 0 to 1. We can see that this makes some parts, such as the man's face in the melons image, much clearer. I also tried this technique on Emir and saw more clarity in the face.

Without Contrasting

With Contrasting

Without Contrasting

With Contrasting