Project 1
Colorizing the Gorskii collection
In this project, I attempted to colourize the digitized Gorskii collection. The collection contains many images, each made up frome a set of 3 greyscale images. These greyscale images represent the images captured by Gorskii, where each greyscale image is a negative of blue, green, red components of the entire coloured image. In this project, I attempt to do 3 things, crop out the edges of the scanned collection, allign each colour to create a final coloured image, and finally, enhance the image as much as possible.
The Core Process
The first step in the process was to crop the edges. I first seperated the images into thirds, then cropped 5% of the image off each edge. This resulted in an image without the black and white borders.
The second step was to allign these images together. This was the hardest part as I needed to find an effecient way to align large images without using a overly computationaly intensive algorithm. The original method was to use the sum of the normalized cross correlation of two pictures (a higher score is better) to calculate how closely the two images aligned. This method worked for smaller jpg images, however, for larger tif images, a better method was needed. For example, checking a range of only 10 pixle horizontal and vertical shifts would create 100 calculations, with some image sizes being up to about 4000x4000 pixles in dimension. Therefor, an image pyramid was used, to scale down the resolution of the images and calculate the alignment, then having a reasonable guess on the horizontal and verticle shifts, the image would then be scaled up, and the guess would be refined. This method called an "image pyramid" dramatically reduced the time it took to align the images.
Finally, having calculated the shifts needed to align the images, the negatives were turned into positives, and stacked to form a 3-channel RGB representation of the coloured image.
Issues, Bells, and Whistles
When NCC Doesn't Work
There are some issues with the algorithm described. For one, if the intensities of the filters a very different, then this method fails to allign the image. You can see this with the image "Emir", where his dress is solid blue. This makes the blue filter very intense in that region, while the other filters are nearly zero. This means the NCC score will be low, depite being in the right region. Using the NCC score method yields the folliwng allignment.
As such, a change was needed. The solution I decided upon was to identify the edges of the image, since the cloak and it pattern made very distinguished lines. Then using the image of just the lines, use those to calculate the shifts needed with the NCC method. The result looked like this:
Finally, the shifts were calculated and the final shifts were applied to the colour filters.
Normalization
Another issue I found was that image normalization helped with the alignment of images. I suspect this is because if the image was very bright to begin with, the difference between NCC scores would be small wherever you shifted the image. Normalization helps with this because it scales the darkest value and brightest values, to the min and max of the intensity range. Therefore, the normalization stretches out the NCC differences, allowing there to be a greater difference between the NCC score of good alignment and the NCC score of of bad alignment.
Black Point adjustment and Contrast Adjustment
Lastly, all the images shown have had an automatic blackpoint adjustment and a manual contrast adjustment. The blackpoint adjustment find the 2nd percentile pixle value of each filter, and zeros them out. This allows the light exposed old filter, to have more distinct blacks.
Gallery
The shifts used for all these images are (shifts of G and R relative to B. [x, y]):
cathedral.jpg [[ 2 5] [ 3 12]] church.tif [[ 3 25] [-4 58]] harvesters.tif [[ 16 59] [ 13 124]] hut.jpg [[ 5 5] [ 6 11]] icon.tif [[17 40] [23 89]] lady.tif [[ 8 56] [ 10 118]] melons.tif [[ 10 83] [ 13 179]] monastery.jpg [[ 2 -3] [ 2 3]] onion_church.tif [[ 25 52] [ 36 108]] roses.jpg [[ 0 5] [-3 11]] sculpture.tif [[-11 33] [-27 139]] self_portrait.tif [[ 29 79] [ 36 176]] spire.jpg [[ 1 5] [ 2 12]] three_generations.tif [[ 13 53] [ 11 112]] tobolsk.jpg [[2 3] [3 6]] train.tif [[ 4 42] [31 86]] emir.tif [[22, 51] [41, 107]]
If unsure what the image name is, use save-as feature of browser, it will display the name of the image.