Assignment 1: Prokudin-Gorskii image alignment using MATLAB
Prokudin-Gorskii captured three photographs for R, G and B color channels by a set of three cameras displaced by some vertical offset. The aim of this assignment is to align these three image channels so that we get a good color image. The images were taken from here. Multiple metrics were experimented with to get a perfect alignment. The alignment was done to sub-pixel levels and small rotaions in the image were also considered. 1.2 Algorithm and implementation The algorithm exhaustively seraches for small shifts to find the correct alignment. It uses edges in the image to find the alignment by using normalized cross correlation (NCC) metric. For very large images, the algorithm creates an image pyramid with three levels. By such a procedure, the serach range in 2-D can be adaptively changed according to the level in the image pyramid. This accelerates the algorithm, hence it is able to find alignment for a 3760*3225 image in 12 seconds! 1.2.1 Algorithm:
1.2.2 Function Description:
2. Find edges in all three channels 3. Using NCC, find the best shifts in X and Y directions on edge images 2. Find edges in all three channels 3. Using NCC, find the best rotation in range -1 to 1 degree for the edge images 2. Create matrices in X and Y directions for sub-pixel shifts 3. Using convolution, apply the matrices and find optimal shifts for the color channel image. Edge image was not considered as edge estimating functions are not sub-pixel accurate. 1.3 Algorithm accelerationThe algorithm can also give alignment for large images such as 3760*3225 image in 12 seconds because:
For the image levels in between, if error in k1 level is 1 pix, then search range in finer level (k2) should be For error in k1 = 1 pix, error in k2 = ceiling(k2/k1) Hence, range = 2ceiling(k2/k1)+1 * 2ceiling(k2/k1)+1 As a precautionary measure I have kept range = 2ceiling(k2/k1)+2 * 2ceiling(k2/k1)+2 1.4 Result Images1.5 Intermediate ImagesFollowing shows the aligned images at various levels in the image pyramid with their corresponding normalised cross correlation (NCC) maps. Note how the NCC map size changes according to level. 1.5 Matlab FilesPlease change the path for the input image. Download all the following files and keep them in the same folder. ass1.m: run this file Rotate function shiftAlign function sPix function |