In 1907, Sergei Mikhailovich Prokudin-Gorskii (1863-1944) [Сергей Михайлович Прокудин-Горский] took color photographs of everything he saw. He accomplished this by using RGB filters and obtaining 3 glass plate negatives, RGB respectively. To view the colored images, we need to align and overlap the three plates. To improve results, it is also a good idea to make adjustments such as cropping, contrasting, white balance, color mapping, etc. The process of reproducing the color image is to be automated in this project.
In this project, we are given input files with channels in the order BGR (as opposed to the conventional RGB). For simplicity, I aligned G and R channels to the B channel. My general approach is to have a fixed channel size of height h and width w . Then, we use an algorithm to find the best coordinate for the left-upper corner of each channel to which I call start .
The first algorithm I adopted is to simply divide the image by three. So the start for BGR would be (0, 0), (h, 0) and (h*2, 0). Then stace them together using numpy.stack. This method gave pretty reliable results with low computation time.
I implemented both Sum of Squared Differences (output_ssd) and normalized cross-correlation (NCC) algorithms. I select a window that is smaller than the channel size to create sub-matrices for G and R channels. The sub-matrices are initialized to either 0 or infinity to suit the metric. This also help with handling out of bound windows.
At first, I tried applying pyramid to the full input image that contains all three channels. It gave a very coarse alignment probably due to extra borders in the input image. Then I was going to use border detection to remove borders then apply image pyramid. However, since I was not able to implement that, I opted for another approach. Instead, I use the displacements of the basic algorithm as starting estimates for the three channels, then create three separate matrices corresponding to each channel. Then, use the three matrices to calculate an estimate alignment.
The displacements are (dy, dx) relative to the blue input image, presented in the order for G, and R channels.
Some pictures of adjustment are omitted since the same result is computed with canny edge detection.
ssd and gradient | adjustments | canny edge detection | |
---|---|---|---|
|
|
||
|
|
||
|
|
ssd and gradient | adjustments | canny edge detection | |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
|
|
|
|
||
|
|
||
|
|
||
|
|
|
ssd and gradient | adjustments | canny edge detection | |
---|---|---|---|
|
|
|
|
|
|
||
|
|