Collin Chin's Programming Project #1 (proj1)

collin.chin@berkeley.edu
cs194-26-abx

Overview

The goal of this project is to take a glass plate image as input and produce a single color image as output. The algorithm works as follows: First, the image is divided into three parts representing the three additive primary colors Red (R), Green (G), Blue (B). Second, each color part is cropped so that computation will only be completed on the inner 70% of each image. Third, a unsharp mask image filter is created for each image.Fourth, the B and G parts are aligned using an image pyramid that recursively searches for the optimal displacement using the sum of squared differences(ssd) as a heuristic. Specifically, each base image B and align image G is scaled down by a factor of two until each of their dimensions fall under a threshold of 256 pixels. Next, using a [-15, 15] pixel window, the align image is shifted until an optimal ssd is found. After, the image is scaled up by two to the previous level and a finer adjustment using a [-1,1] pixel window is made at each successive level until the original image size is reached. The same image pyramid and alignment is then used to find the optimal offset for the B and R parts. Fifth, each G and R image was shifted by their offsets and combined with the base B to create a RGB colorized image. Sixth, crop borders using hough lines. Seventh, apply color contrasting by adjusting image stretching limits. Eighth, print the image and save the result.

Problems

The algorithm worked smoothly on all images except for Emir of Bukhara prior to bells and whistles. The issue was that the images R and G to be matched to B did not actually have the same brightness values resulting in the left image. A temporary solution was to align the Blue and Red to the Green. The full solution was to use edge detection by creating an unsharp mask image filter using imgaussfilt() and subtracting the original image. This increased the performance of the ssd method and removed the interference from any blue color.

Results

Image Green to Blue Offset Red to Blue Offset
cathedral.jpg [5, 2] [12, 3]
emir.tif [49, 24] [110, 56]
harvesters.tif [60, 17] [124, 13]
icon.tif [41, 17] [81, 23]
lady.tif [55, 9] [118, 12]
monastery.jpg [-3, 2] [3, 2]
nativity.jpg [3, 1] [8, 0]
self_portrait.tif [79, 29] [176, 37]
settlers.jpg [7, 0] [15, -1]
three_generations.tif [53, 14] [111, 11]
train.tif [42, 6] [86, 32]
turkmen.tif [56, 21] [116, 28]
village.tif [65, 12] [137, 22]
bridge.jpg [4, -1] [14, -2]
dome.jpg [4, -1] [13, -2]
tracks.jpg [4, -3] [14, -7]
prisoners_of_war.jpg [3, 1] [12, 2]
monument.jpg [1, 3] [8, 5]
wharf.jpg [2, 0] [-3, -14]

Failures

failures: most likely due to damage in original photograph and sensitivity in algorithm to extreme colors

Bells and Whistles

ding ding toot toot

Unsharp Mask Image Filter

base image(left) is sharpened by subtracting a blurred (unsharp) version of the image from itself using imsharpen (right)

Border Cropping using Hough line

extract border line endpoints from base image(left) based on Hough transform
1. create a binary black and white image on 10% of every border
2. create a hough transform using the binary image using houghlines()
3. find peaks in the hough transform of the image using houghpeaks()
4. determine the endpoints of the longest line segment
5. crop segments from original image to get result(right)

Image saturation adjustment

base image(left) has RGB image intensity values adjusted resulting in the image on the right
1. find limits to contrast stretch image using strechlim
2. adjust image intensity using top and bottom 6% as limits using imadjust

The last five additional images and one failed image were collected from http://www.loc.gov/pictures/