The goal of the project was to take the digitized Prokudin-Gorskii glass plate images and produce a colored image.
Since .jpg files are small, it was possible to exhaustively search the entire image within a range of [-15, 15] in both horizontal and vertical directions. However, for .tif files, a different approach was necessary. The .tif images had to be recursively aligned via an image pyramid, starting from lower to higher resolutions, with each level of resolution scaled by a factor of 2.
Firstly, I started with Sobel edge detection. The thought process behind using it was that if I could identify edges, then I would have another feature to align the three channels on. "Surely this would help," I thought.
To my surprise, this did a great deal, especially for the Emir image.
To my understanding, Sobel detection works by identifying edges by calculating the gradients for each pixel. I used Sobel in two ways. One was during the alignment process, where I would iterate over the x-gradients and y-gradients to find the best alignment.
The second use of Sobel was in post-processing for auto cropping.
I then constructed an auto-crop feature. The motivation behind this was to remove unsightly borders.
I used Sobel here as well. I generated a mask on a grayed version of the image. Afterwards, I created a threshold where I checked if the output edges were in the 95th percentile. If they were, I would iterate over the rows and columns of that section of the image and determine the boundaries of the image.
Finally, to ensure that I didn't shave off too much of the image, I added a limit to how much could be cropped.
Lastly, I created an auto-contrast function. Some of the images were a bit too unrealistic to be photographs and were missing details, so I decided to add auto contrast.
Originally, I planned to implement the functionality of cv2.exposure.equalize_adapthist()
myself. However, my implementation added some runtime and made the images grainier,
so I decided to stick with OpenCV's implementation instead.