Project 1: Hybrid Images

mashby's writeup

Pyramid algo

The first thing to do (after the images are loaded an aligned, thanks support code) is construct Gaussian and Laplacian Image Pyramids. Here's what I do: Start with the original image, which is the base of the Gaussian pyramid, and create a blurred version. I filtered with a 7x7 Gaussian kernel with sigma=1. Then subtract the blurred version from the original. This gives the base of the Laplacian pyramid. Subsampling the blurred version now to get a smaller image (half the length and half the width) gives the second level of the Gaussian pyramid, call it G2. Blurring G2 and then subtracting the blurred version from G2 gives the second level of the Laplacian pyramid, and then subsampling that blurred version of G2 gives G3, and so on until you reach N, at which time a N-level Laplacian pyramid and an N-level Gaussian pyrmaid have been constructed for the image. Do this for both images to be combined.

Constructing the hybrid

In my hybrid reconstruction, my function takes the Gaussian and Laplacian pyramids from both of the two images to be combined, as well as two cutoff numbers to indicate at what level of the pyramid to start integrating the other picture. Call the picture to have high frequency in the hybrid (the one that you can see close up) H, and the other picutre L (for low frequency). Rather than rebuild the picture from the pyramid starting with the hightest, most blurred level of L's Gaussian pyramid, I instead start with the level in L's Gaussian pyramid that corresponds to the second cutoff number. This is theoretically the same as iteratively upsampling, blurring, and adding back Laplacian levels up to the cutoff to reconstruct L, but I found that in practice I got better results simply using that corresponding level of L's Gaussian pyramid. Then, starting with that level, I upsample (using imresize), blur the result, and add back the corresponding level from H's Laplacian pyramid (the first level that gets added in in the level of L's Laplacian that corresponds to the first cutoff number). Then this process is repeated until the base of L's Lapalacian pyramid has been added into the picture. The result is a nice hybrid image with the high frequencies from H and the low freqencies from L.

Extra Credit: Colors

As an extension, I made the hybrid image construction work with colored images. This is achieved simply by separating the image into its three channels, R, G, and B, and performing the above algorithms on each channel as if it was it's own grayscale image. The results are three grayscale hybrids for each channel that can the be combined into a single color hybrid image. I found the best results were achieved when channels were treated completely separately, that is, contructing three pairs of pyramids for both the high-frequency and for the low-frequency component images.

Results

The results look OK, though its clear that for this particulr algorithm, the success of the hybrid image in entirely dependent on the source images an their inherent similarity. I chose to do a series of hybrid pictures of currency, because currency has a set structure which can be conveniently exploited in creating hybrids. Even with that structure, the results varied widely in quality and effectiveness (the $10 to $5 one is by far my favorite). Adjusting the cutoff for different pairs was also crucial in making a good hybrid. So all in all, the algorithm can produce cool results, but special artistic attention has to be given to the size of the Gaussian filter being used (though I mainly stuck with the 7x7), the cutoff frequency, and the compatability of the selected images.

Look at the currency hybrids again

Look at data folder hybrids again