CS194 Project 1 - Jing Yuan

CS194 - 26 Intro to Computer Vision and Computational Photography

Project 1 - Images of the Russian Empire: Colorizing the Prokudin-Gorskii Photo Collection

By Jing Yuan [Email: jingyuan10@berkeley.edu]


Overview

The goal of this assignment is to take the digitized Prokudin-Gorskii glass plate images and, using image processing techniques, automatically produce a color image with as few visual artifacts as possible In order to do achieve this goal, extraction of the three color channel images, placing them on top of each other, and alignment of the color channel images are needed to create a single RGB color image.

Methodology

The input is a glass late image with three figures taken under RGB filters separately The work flow of this project is: 1> Separate the raw figure into three part (in the order of B, G, and R); 2> Use possible metrics (SSD or NCC) to score how well the images match; 3> Align three figures together and form a colorful figure In order to improve the performance of the code, I optimize the displacement of small and large figures in two algorithms.

Picture align Solution for small figure

First of all, I develop the align method for small figures (.jpg in this project) Firstly, I corp the raw figure into three part by evenly separating the height into three parts Then, I use 70% of the total figure to match those three figures, which was cropped from the center of the figure After that, using Blue channel as reference image, I match Green and Red channels with Blue channel respectively by searching over a window of possible displacements, [-20,20] pixels Finally, I overlap three figures together after applying the optimal displacements In this process I used both sum of Squared Differences (SSD) and normalized cross-correlation (NCC) and the results turned out that NCC worked better than SSD, thus I used NCC as the matching metric for all the figures.

While this solution works alright with small images, the problem becomes that this is terribly inefficient and that I would need to expand the window size of possible displacement vectors from [-20,20] to something much larger for bigger images Therefore, a better algorithm is needed for the large figures.

Picture align Solution for large figure

To allow for processing on much larger images, referring to the .tif files in this project, I added a function implementing image pyramid scheme, which scaled the image down by n-fold of their original size Once the width of the figure is smaller than 500 pixel and number of the folder is larger than 9, the function returned the best scale-down fold Then, there will be two optimization process for large figures In the 1st optimization, the scaled image went through all the optimization process of the small figure and I will get the estimated best displacement for the scaled figure, and I scaled that up by n Then, in the 2nd optimization, I checked around that vector for some small radius [-10, 10] pixel in both vertical and horizontal direction I only use 30% of the total figure to find the optimal displacements for the 2nd Optimization.

I then take the best estimate for a displacement vector and apply that to the original image, thus obtaining an effective and much more efficient best displacement vector with which to overlap the images together.

Bell & Whistles: Automatic cropping

I also tried to crop the image borders by detecting the edges between the borders and the image First, I inspect each raw figures and find that the boarder are always black and white So, starting from the edge of the figure, I search rightward and the upward the figure to the middle of the figure separately, If the value of the pixel larger than 0.1 (representing black) and also smaller than 0.9 (representing black), the searching will stop and return the corp-width and corp-height that are needed to be cropped from the figure And I also choose 20 start points along the width or height of the figure Then, I remove the largest and smallest corp-width and corp-height and average out the remaining corp-width and corp-height as the final size.

But, from the results I find that this algorithm successfully crop the white borders In some figures, the black borders still exist So, I re-inspect the figure, I find that the borders are not purely white or black The possible solution could be that increasing the contrast of the figure.


Results

Note:

Offset Vector (dy,dx).
If dx>0,it means the corresponding picture will move downward
If dy>0,it means the corresponding picture will move rightward

There are three figures from right to left: Raw figures, Aligned figures, Cropped figures


Cathedral

1st Opt: Green Offset Vector: (2,5) Red Offset Vector: (3,12)
Running time: 1.78s




Emir

1st Opt: Green Offset Vector: (24,48) Red Offset Vector: (40,104)
2nd Opt: Green Offset Vector: (24,47) Red Offset Vector: (31,95)
Running time: 19.4s




Harvesters

1st Opt: Green Offset Vector: (16,56) Red Offset Vector: (16,120)
2nd Opt: Green Offset Vector: (17,59) Red Offset Vector: (15,124)
Running time: 19.7s




Icon

1st Opt: Green Offset Vector: (16,40) Red Offset Vector: (24,88)
2nd Opt: Green Offset Vector: (18,41) Red Offset Vector: (23,90)
Running time: 20.3s




Lady

1st Opt: Green Offset Vector: (8,56) Red Offset Vector: (8,112)
2nd Opt: Green Offset Vector: (9,51) Red Offset Vector: (11,114)
Running time: 23.0s




Melons

1st Opt: Green Offset Vector: (8,88) Red Offset Vector: (16,160)
2nd Opt: Green Offset Vector: (10,84) Red Offset Vector: (13,170)
Running time: 21.5s




Monastery

1st Opt: Green Offset Vector: (2,-3) Red Offset Vector: (2,3)
Running time: 1.97s




Onion church

1st Opt: Green Offset Vector: (24,48) Red Offset Vector: (40,104)
2nd Opt: Green Offset Vector: (26,50) Red Offset Vector: (37,108)
Running time: 21.7s




Self Portrait

1st Opt: Green Offset Vector: (32,80) Red Offset Vector: (32,160)
2nd Opt: Green Offset Vector: (29,77) Red Offset Vector: (36,170)
Running time: 21.1s




Three gnerations

1st Opt: Green Offset Vector: (16,56) Red Offset Vector: (16,112)
2nd Opt: Green Offset Vector: (15,50) Red Offset Vector: (13,110)
Running time: 20.2s




Tobolsk

1st Opt: Green Offset Vector: (3,3) Red Offset Vector: (3,6)
Running time: 1.74s




Train

1st Opt: Green Offset Vector: (8,48) Red Offset Vector: (32,88)
2nd Opt: Green Offset Vector: (7,42) Red Offset Vector: (33,86)
Running time: 21.6s




Castle

1st Opt: Green Offset Vector: (0,32) Red Offset Vector: (8,96)
2nd Opt: Green Offset Vector: (2,34) Red Offset Vector: (5,98)
Running time: 20.3s




Workshop

1st Opt: Green Offset Vector: (0,56) Red Offset Vector: (-8,104)
2nd Opt: Green Offset Vector: (0,53) Red Offset Vector: (-12,106)
Running time: 21.4s




Own choosing

Stone

1st Opt: Green Offset Vector: (0,40) Red Offset Vector: (-8,152)
2nd Opt: Green Offset Vector: (-1,39) Red Offset Vector: (-7,151)
Running time: 21.4s




Tree

1st Opt: Green Offset Vector: (-40,72) Red Offset Vector: (-64,112)
2nd Opt: Green Offset Vector: (-41,75) Red Offset Vector: (-67,113)
Running time: 20.2s