CS194 Project 1 (Draft-ish)

The goal of this project was to create a colored version of the images taken by Prokudin-Gorskii in early 20th century Russian Empire.

Aligning Images

To find the best way to align images, I used the canny edge detector module from scikit-image library. I selected one of the 3 layers (b,r, or g) as a fixed imaged and rolled the other two images on it. I also cropped the edges before aliging them. I used least squares to find the difference between two images. I didn't use ncc because images produced by canny edge detector are black and white (so any pixel is either 1 or 0) and therefore the luminosity of the image did't matter and ncc would not have given me better results (I tried it too). To speed the alignment process up, I used image pyramids as described in the spec. After experimenting with different values, I realized that when the image's width/ height is smaller than 64, and when the window of displacement at any layer is large, it is more likely that the 3 layers get aligned incorrectly.

I also tried to aligning the images based on all 3 layers(I first aligned g with b and r with b, then I tried aligning b with g and r with g, and did a similar thing with red) After comparing the images I noticed that aliging based on the green layer creates much better colored images in most cases.
Here is an example: aligned with all colors
(Note: I hadn't implemented image pyramid correctly (so the image at top of the pyramid was still too large) I did this comparison the difference in the correct version was much much less noticable).

Auto-crop


I used edge detection again to autocrop the images. I resized the images so that the maximum height/length could be 128 and then used the canny edge detection module to detect the lines. Since the image created by the edge detection method I used can only be white and black (white represents the lines). I chose a relatively small window (around 10 pixels on each side for the resized images) and found the column/ row with maximum brightness and cropped everything before/after that line (depending on which side of the image I was working on).

The lines that I wanted to crop were in one of the following 3 catagories:

1) the black/white edge around each layer/ image


2)2) blue green/ red green layers were not perfectly aligned in the edges


3) red and blue were not perfectly aligned in the edges


I first found how much each image needs to be cropped on each side and I recropped that image using the same algorithm but on a smaller window (5 on each side) agian. Here are some example: emir - autocrop lady - autocorp

adjusting color/contrast

I am pretty satisfied with the images that my code created but I used other funcitons in scikit-image libarary to play around with color and contrast and compared them to see which one would look better


Here's an example of that comparison:
color ajustment

I figured that images created using skimage.exposure.equalize_adapthist looked better in most cases so I decided to apply that to all of the cropped images.



The following is the result: The left column are images that I made after aliging, and cropping the input image and the right column are same images with equalize_adapthist applied to them results
results
results
results
results
results
results