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)

 

00149v.jpg

(4, 2) (9, 2)

 

00153v.jpg

            (7, 2) (7, 13)

 

00163v.jpg

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

 

00194v.jpg

            (4, 2) (7, 4)

 

00398v.jpg

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

            (5, 3) (12, 0)

 

00952v.jpg

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

 

01167v.jpg

            (5, 0) (12, -2)

 

01656v.jpg

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:

 

00458u.tif

            (93, 34) (51, 7)

 

01043u.tif

            (-17, 9) (10, 17)

 

01047u.tif

            (25, 20) (71, 33)

 

01657u.tif

            (55, 9) (116, 11)