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)

NCC on Cathedral
Offset: R: (12, 3), G: (5, 2)

2. Multi-Scale Search¶
SSD on Emir
Offset: R: (103, 57), G: (49, 24)

NCC on Emir
Offset: R: (104, 56), G: (49, 24)

SSD on Harvesters
Offset: R: (124, 13), G: (59, 16)

NCC on Harvesters
Offset: R: (124, 13), G: (60, 17)

SSD on icon
Offset: R: (90, 23), G: (41, 17)
![]()
NCC on icon
Offset: R: (89, 23), G: (41, 17)
![]()
SSD on lady
Offset: R: (116, 11), G: (56, 8)

NCC on lady
Offset: R: (117, 12), G: (55, 8)

SSD on self_portrait
Offset: R: (155, 31), G: (79, 29)

NCC on self_portrait
Offset: R: (155, 31), G: (79, 29)

SSD on three_generations
Offset: R: (112, 11), G: (53, 14)

NCC on three_generations
Offset: R: (112, 11), G: (53, 14)

SSD on train
Offset: R: (87, 32), G: (42, 6)

NCC on train
Offset: R: (87, 32), G: (42, 6)

SSD on turkmen
Offset: R: (116, 28), G: (56, 21)

NCC on turkmen
Offset: R: (116, 28), G: (56, 21)

SSD on village
Offset: R: (138, 22), G: (65, 12)

NCC on village
Offset: R: (138, 22), G: (65, 12)

3. A few examples of my own choosing¶



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:

After cropping:

Better features.¶
I used Sobel operator to detect edges and then used NCC to measure the similarity.
Original NCC:

Edge feature:

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:

After Auto contrasting:
