This project reconstructs historical photographs by aligning color channels from early 20th-century images. The images have exposures with three color channels: red, green, and blue. The reconstruction process involves computing the displacement between channels and aligning them to create full-color images.
First, the red, blue, and green plates are isolated from the image. Then, a window of [-15, 15] is used to try various displacements and find the one that results in the smallest Euclidean distance. I crop 5% from each side of the image in order to reduce noise from the borders. I do this for both green and red and align them to blue. This works well for small jpgs that are relatively small and can afford to search this window size.
However, for the larger .tif images, they are too large to attempt this same method. Thus, an image pyramid is used in order to gradually scale the image down by a factor of 0.5 repeatedly until the image reaches a similar size to the first example jpg I used. (I checked this by ensuring max[height, width] was less than 400 pixels). Then, a similar approach with the window search range of [-15, 15] is used for the smallest scale image in order to find the optimal displacement for red and green. These displacements are then reused and scaled up for each image respectively, with small searches in windows of size [-4, 4] in order to account for extra pixels that form when rescaling back up. Finally, at the end 5% from each edge is cropped to eliminate most of the noisy borders. For the most part, this aligned most images well, with only the Emir image being slightly misaligned.
A problem I had was that there would be instances in which there was slight misalignment at the end. I addressed this by increasing the search window on the later levels from [-1, 1] to [-4, 4]. Again, the Emir wasn't aligned perfectly, but this could be due to the fact that the alignment was on the blue channel, but the image also has a lot of blue and little green, which could explain the green plate being slightly out of place still.
Colored image of a cathedral.
Displacement: R (2, 5); G (3, 12).
Colored image of a monastery.
Displacement: R (2, -3); G (2, 3).
Colored image of Tobolsk.
Displacement: R (2, 3); G (3, 6).
Colored image of a church.
Displacement: R (3, 25); G (-5, 58).
Colored image of the Emir.
Displacement: R (24, 49); G (43, 88).
Colored image of harvesters.
Displacement: R (15, 60); G (13, 124).
Colored image of an icon.
Displacement: R (17, 41); G (23, 89).
Colored image of a lady.
Displacement: R (8, 55); G (12, 111).
Colored image of melons.
Displacement: R (9, 82); G (11, 177).
Colored image of an onion-shaped church.
Displacement: R (26, 51); G (36, 108).
Colored image of a sculpture.
Displacement: R (-11, 33); G (-27, 140).
Colored self-portrait.
Displacement: R (29, 79); G (34, 175).
Colored image of three generations of people.
Displacement: R (13, 55); G (10, 112).
Colored image of a train.
Displacement: R (6, 42); G (32, 87).
Colored image of a bell.
Displacement: R (16, -100); G (21, -62).
Colored image of a canal.
Displacement: R (24, 27); G (49, 46).
Colored image of a cottage.
Displacement: R (12, 23); G (24, 94).
Colored image of a flowers.
Displacement: R (20, 31); G (35, 82).
Colored image of a gothic church.
Displacement: R (-19, -9); G (-51, -5).
Colored image of a river.
Displacement: R (-23, 34); G (-52, 62).
For my bells & whistles, I implemented Sobel edge detection in order to perfectly align the Emir image that was failing before. I approached it by applying Gaussian Blur in order to reduce noise and smoothen the image. This is important because derivatives are important in edge detection and they are especially sensitive to this. Then the convolution with the Sobel operator derivative masks for edge detection will be less sensitive to noise. Then, the gradient magnitude of the X and Y directions normalized is used as the metric for comparison. This fully aligned the Emir successfully, in combination with a later layer search window of [-2, 2] to account for extra pixels when scaling up. I imported Gaussian Blur and Convolution operations to make life a bit easier. This ultimately resulted in better alignment, but the runtime increased to just under an minute per .tif image. I also increased crop for alignment to 15% and increased the intial search window to [-50, 50].
Colored image of the Emir with Euclidean distance.
Displacement: R (24, 49); G (43, 88).
Colored image of the Emir with Sobel edge detection.
Displacement: R (23, 49); G (40, 106).
Also referenced Bryan Li's formatting of images for his site. https://inst.eecs.berkeley.edu/~cs180/fa23/upload/files/proj1/bryanli0/