Computational Photography – Assignment 1

by Jason MacAllister


            For Assignment 1, we were given a number of black and white photographs taken in Russia at the (last) turn of the century.  By using red, green, and blue filters, the photographer was able to produce images corresponding to each of these three colors (see below).  Our task was to align the three layers to produce a color image.  Using Matlab, two of the images are aligned with the third using either the Sum of Squared Differences (the lowest value for a particular alignment denotes the best match) or the Normalized Correlation (higher correlation = better alignment).   I found that Normalized Correlation was a better method for all the large .tif files, and frequently resulted in better results with the smaller .JPEGs.  Time required for alignment was greatly decreased by implementing a Gaussian Image Pyramid, in which consecutively smaller images are computed until an ideal minimum is reached (my determinant was whether it had less than 1000 pixels).  Then, starting from the bottom, the image is shifted by a very small number of increments over the base image (I found nine to be acceptable).  Each displacement is sent to the larger image as a starting point until the total displacement for the entire image is found.


Other relevant details: I removed the line fullim = im2double(fullim); from my code.  I learned that image matrices should be in the double format when performing mathematic calculations on them, but I found that the larger files would run a HECK of a lot faster without ever converting the matrices.

            I removed the borders of each image before performing any shifting on them.  I found that 20 pixels was good to remove all around for the smaller files, and since the larger files are about 10x the size, I removed 200 pixels from each edge.


Example of the original three-image set.



Completed Images:

(Displacements are listed at bottom of picture in the format (greenRow, greenColumn) (redRow, redColumn)



(4, 2) (9, 2)



            (7, 2) (7, 13)



            (-3, 1) (-5, 1)



            (4, 2) (7, 4)



Probably the worst job.  I tried both SSD and NC, and NC yielded this better but still lacking image.

            (5, 3) (12, 0)



            (2, -2) (7, -4)



            (5, 0) (12, -2)



Another bad result that fiddling wouldn’t fix.  Incidentally, I never had

to fiddle with any of the other files, except for 00153v.jpg

            (7, 0) (12, -1)



And these are the large files, which have been shrunken down to a reasonable size for display:



            (93, 34) (51, 7)



            (-17, 9) (10, 17)



            (25, 20) (71, 33)



            (55, 9) (116, 11)