Project 1

Colorizing the photos of Prokudin-Gorskii

Simple approach overview

The basic approach I used for small images (and also larger ones, in conjunction with an image pyramid) is to, given an image to adjust (img) and a reference image (ref), have some x window and y window (-15 to 15 px for both) across which img slides and is compared to ref using the norm of the difference between the images (i.e. the euclidean distance between the flattened vectors of the images). The shift that produces the euclidean distance is stored, along with the corresponding shifted image. In order to ignore the shifted borders, both images are cropped before the norm is calculated to exclude the parts of the images that might be affected by the shift.

Simple approach images (.jpg files)

cathedral g: (5, 2), r: (12, 3) monastery g: (-3, 2), r: (3, 2) tobolsk g: (3, 3), r: (6, 3)
cathedral monastery tobolsk

Pyramid approach overview

For larger images (.tif images), I used an image pyramid for faster processing. I created an array of images for each red, green, and blue negative, by resizing the images with scales 0.5, 0.25, etc. until the next scale would cause the image to be too small (less than 100 px vertically). Then, for the lowest resolution r, g, and b images, I aligned the red and green channels to the blue channel using the above algorithm, storing the offsets for r and g. Then, for the next highest resolution, I repeat the algorithm with the window of offsets around 2 * the previous offset, + or - 2 pixels because that is the scaling factor between images. I repeat this until we get to the highest resolution image, to get the full-resolution offsets, then stack the image channels.

harvesters g: (59, 16), r: (124, 13) icon g: (41, 17), r: (89, 23) lady g: (56, 8), r: (116, 12) melons g: (81, 10), r: (178, 13) onion church g: (51, 27), r: (108, 36)
cathedral monastery tobolsk cathedral monastery
self portrait g: (79, 29), r: (176, 37) three generations g: (53, 14), r: (111, 11) train g: (42, 6), r: (87, 32) workshop g: (53, 0), r: (105, -12)
tobolsk monastery tobolsk tobolsk

Emir and Church

The images Emir and Church did not work perfectly with the parameters and methods from above. The fix for church was easy: to make the window of pixel shifts to scan smaller, from -5 to 5 in the x and y dimensions. Initially, at 15 pixel offsets for the 100 px images, the offsets would get unreasonably large, likely because of the coloration/shadows of the church and the sky. Altering this hyperparameter of initial offsets worked well.

Emir was a more difficult image, because the dark, vibrant blue of Emir's robes make the red and blue negatives extremely different in brightness values for his clothing. To remedy this, I aligned both red and blue channels with green, rather than using blue as the comparison standard, because green is the more average channel in this case.

emir r: (57, 17), b: (-49, -24) church g: (25, 4), r: (58, -4)
tobolsk monastery

Additional photos

Additional photos from the collection, ran using the pyramid algorithm (no parameter/algorithm adjustments were needed)

people g: (57, 31), r: (130, 49) garden g: (73, 14), r: (148, 23) brook g: (-3, -10), r: (2, -9)
tobolsk monastery monastery