CS143: Introduction to Computer Vision



Home

Project 1: Hybrid Images


Description of algorithm

Building the Gaussian and Laplacian pyramids

Firstly I build the Gaussian pyramid for both images. To create the pyramid I filtered the image with a Gaussian filter with standard deviation of 1.6 and of size [5,5]. Through experimentation, values around 1.6 seemed to produce the best results.

After filtering I subtracted the filtered image from the prefiltered one. I stored the residue of the subtraction in a struct, as the first level of the Laplacian pyramid. I stored the filtered image in a different struct that should ultimately contain the entire Gaussian pyramid of the image. After storing both of these, I downsized the filtered image by a factor of 2 using a bilinear interpolation. I repeated these steps as many times as levels were passed in as an input.

Creating hybrid images

Once the pyramids have been created, we can ignore the Gaussian pyramid and focus on the Laplacian. To create the hybrid I took low frequencies of image1 and the high frequencies of image2. The cutoff determined how much low frequency vs. high frequency data I took. For the best results I chose the cutoff to be level 6 out of 10. In this way I placed slightly more emphasis on the higher frequencies. To actually construct the image I took the top of the Gaussian pyramid for image 1 and added onto as many levels of the top of the Laplacian pyramid as indicated by (size-of-Pyramid)-cutoff1-1. The reason why this indexing is a little counter-intuitive is because in my struct I stored the lowest level of the pyramid in the lower indices, and the higher levels in the higher indices.

Once I am done adding the levels of the Laplacian pyramid of image1, I add the remaining levels of image2 onto this sum. So let's say there's a total of 10 levels and the cutoff is 3. I would firstly add the 10th level of the Gaussian pyramid of image 1 with the 10th, 9th and 8th levels of the Laplacian of image 1. Onto this I would add levels 7,6,5,4,3,2,1 of the Laplacian pyramid of image 2. This total sum will yield the final hybrid.

Note that every time I wish to add two levels together I need to upscale the smaller image(the one higher on the pyramid) to ensure that it has the same size as the image from the level below it.


Parameters and Results

Below I summarize the values that I chose for the parameters when creating the hybrids of the images I selected, as well as the sample images. The results obtained contain a good amount of noise. The poorest results were obtained in the car-rhino and the Presley-Chavan hybrid. On the other hand, the results are particularly good for Jesus-Depp and for Pitt-Obama. The reason for this is that the low frequency images selected are iconic and easily recognisable by the viewer. Hence, they do not disrupt the high-frequency image when you look from up close, but are easily recognisable from afar. The same is true for the Marilyn-Einstein hybrid. Textures on faces also seem to work quite well, as seen on Derek's face. Although clearly not perfect, the algorithm does a pretty good job overall.

Hybrid Image N Cutoff
Jesus-Depp 10 6
Pitt-Obama 10 6
Chavan-Presley 10 6
Nutmeg-Derek 10 6
Marilyn-Einstein 10 7
Car-Rhino 10 6

Jesus-Depp



Pitt-Obama



Presley-Chavan



Nutmeg-Derek


Marilyn-Einstein


Car-Rhino