16-726 Assignment #1¶

by Zi Wang (ziwang2)

Brief Overview¶

In this assignment, I implemented the Sum of Squared Differences (SSD) distance and normalized cross-correlation (NCC) metrics that are used to score how well the images match. In addition to single-scale search, I implemented the multi-scale (image pyramid) searching algorithm to speedup to handle large images. For extra credits, I implemented (1) Pytorch implementation. (2) Automatic cropping. (3) Automatic contrasting. (4) Better features.

1. Single-Scale Search¶

SSD on Cathedral

Offset: R: (12, 3), G: (5, 2)

'image'

NCC on Cathedral

Offset: R: (12, 3), G: (5, 2)

'image'

2. Multi-Scale Search¶

SSD on Emir

Offset: R: (103, 57), G: (49, 24)

'image'

NCC on Emir

Offset: R: (104, 56), G: (49, 24)

'image'

SSD on Harvesters

Offset: R: (124, 13), G: (59, 16)

'image'

NCC on Harvesters

Offset: R: (124, 13), G: (60, 17)

'image'

SSD on icon

Offset: R: (90, 23), G: (41, 17)

'image'

NCC on icon

Offset: R: (89, 23), G: (41, 17)

'image'

SSD on lady

Offset: R: (116, 11), G: (56, 8)

'image'

NCC on lady

Offset: R: (117, 12), G: (55, 8)

'image'

SSD on self_portrait

Offset: R: (155, 31), G: (79, 29)

'image'

NCC on self_portrait

Offset: R: (155, 31), G: (79, 29)

'image'

SSD on three_generations

Offset: R: (112, 11), G: (53, 14)

'image'

NCC on three_generations

Offset: R: (112, 11), G: (53, 14)

'image'

SSD on train

Offset: R: (87, 32), G: (42, 6)

'image'

NCC on train

Offset: R: (87, 32), G: (42, 6)

'image'

SSD on turkmen

Offset: R: (116, 28), G: (56, 21)

'image'

NCC on turkmen

Offset: R: (116, 28), G: (56, 21)

'image'

SSD on village

Offset: R: (138, 22), G: (65, 12)

'image'

NCC on village

Offset: R: (138, 22), G: (65, 12)

'image'

3. A few examples of my own choosing¶

'image'

'image'

'image'

4. Extra Credits¶

Pytorch Implementation¶

I use pytorch to implement the alignment, rescale, stacking and so on. The aligned images are the same as the previous ones. Please refer to my code (main_hw1_pytorch.py) submitted to Gradescope for details.

Automatic cropping.¶

I implemented a function which automatically identifies and isolates the largest object in an image by converting the image to grayscale, thresholding to separate foreground and background, labeling connected components, finding the largest component, and cropping the image to this component's bounding box.

Before cropping: 'image'

After cropping: 'image'

Better features.¶

I used Sobel operator to detect edges and then used NCC to measure the similarity.

Original NCC: 'image'

Edge feature: 'image'

Automatic contrasting.¶

I wrote a function that enhances the contrast of a color image by applying histogram equalization to each of its color channels separately, making the image's details more visible and improving its overall appearance.

Before Auto contrasting: 'image'

After Auto contrasting: 'image'