Computational Photography Programming #1

Matt Dee (medee@andrew)

At a high level, this implementation works by recursively scaling the image down to half of its size until it gets too small (in this case, when one dimension was less than or equal to 500 pixels). Then, it searches a all possible displacements of at most 20 pixels in any dimension, scoring them using the sum of squared differences for each pixel. This allows it to handle displacements of at most 4% the total image size, which was sufficient for all images I used.

Then, once it has calculated that offset, it goes back to the next larger level, applies the last offset, multiplied by two, and searches for displacements up to 4 pixels in any direction. This allows it to adjust to the smaller level being off by a bit. Once we reach the top level, we have the offset.

One trick that was necessary to get this to work was to ignore the edges of the image. In my implementation, I ignored the outer 3/4 in every dimension (3/8 on either side). This ensures that the edges of the panes do not mess with the scoring.

Another thing that helped was normalizing each of the color channels at the beginning (I divided each channel by the sum of the entire channel). This is because, in images like 00087u.tif, with a bright single-color thing (the rug in this case), it would favor putting the bright single-color area out of the image, since even when it was in the right place, the red channel would be very different.

With these two tricks, it seems to have worked on every image provided, plus a few that I chose from the library.

On the large .tif files, this implementation takes 20-30 seconds. This could probably be sped up by decreasing the displacement that we search on the larger versions, but this speed was tolerable and worked.

.jpg files


00106v.jpg
gy=4, gx=1 ry=9 rx=-1



00757v.jpg
gy=2, gx=3 ry=5 rx=5



00888v.jpg
gy=6, gx=1 ry=12 rx=0



00889v.jpg
gy=2, gx=2 ry=4 rx=3



00907v.jpg
gy=2, gx=0 ry=6 rx=-1



00911v.jpg
gy=1, gx=-1 ry=13 rx=-1



01031v.jpg
gy=1, gx=1 ry=4 rx=2



01657v.jpg
gy=5, gx=1 ry=12 rx=1



01880v.jpg
gy=6, gx=2 ry=14 rx=4



.tif files


00029u.tif
gy=39, gx=16 ry=90 rx=34

Full res .tif


00087u.tif
gy=48, gx=38 ry=107 rx=55

Full res .tif


00128u.tif
gy=35, gx=25 ry=51 rx=38

Full res .tif


00458u.tif
gy=43, gx=6 ry=87 rx=32

Full res .tif


00737u.tif
gy=15, gx=7 ry=49 rx=14

Full res .tif


00822u.tif
gy=57, gx=25 ry=125 rx=33

Full res .tif


00892u.tif
gy=16, gx=2 ry=42 rx=4

Full res .tif


01043u.tif
gy=-16, gx=10 ry=11 rx=17

Full res .tif


01047u.tif
gy=24, gx=20 ry=71 rx=33

Full res .tif


Selected files from collection


coll1.tif
gy=31, gx=4 ry=114 rx=7

Full res .tif


coll2.tif
gy=48, gx=19 ry=100 rx=20

Full res .tif


coll3.tif
gy=3, gx=19 ry=-12 rx=20

Full res .tif


coll4.tif
gy=85, gx=4 ry=181 rx=-2

Full res .tif