Sep 26, 2011

Making a hybrid image

Sungmin Lee

1. Abstract

In this assignment, I generated Gaussian and Laplacian pyramids from two each image respectively. After building each pyramid, I build a hybrid pyramd which has some parts of high frequency from one image, and has some parts of low frequency from the other image. By reconstructing this pyramid from the lowest frequency domain, I was able to yield a hybrid image.

2. Algorithm

First of all, I generated Gaussian pyramid by applying Gaussian filter and down sampling the image for each level. Since Laplacian image of original image is

L0 = I0 - G0

,where I0 is original image, G0 is Gaussian filtered image, and L0 is laplacian image, I could repeatedly build each Gaussian and Laplacian pyramid for each level of image.

Input:
image (original image)
Data Structure:
gaussian[] (array of gaussian images)
laplacian[] (array of laplacian images)
Functions:
gaussianFilter(width, height, sigma) - generate gaussian kernel
applyConv(target, filter) - apply convolution(filter) to the target
resize(target, ratio)
Algorithm:
gau_kernel ← gaussianFilter(5, 5, 3)
for i from 1 to Number of Layer by 1
   temp ← applyConv(image, gau_kernel)
    gaussian[i] ← temp
    laplacian[i] ← image - temp
    image ← resize(temp, 1/2)

<Algorithm 1. Generating Gaussian and Laplacian pyramids >

Once you build Gaussian and Laplacian pyramids from each two image respectively, the next step is generating a hybrid pyramid from two each laplacian pyramid. Let's suppose you set a cutoff as 2, and this means that you would have 2 high frequency layers from one image, and take the rest of lower layers from the other image. Once you buiild an hybrid image, you can simply reconstruct the image pyramid by upscailing from the bottom and sum to upper level of laplacian image repeatedly.

Input:
gaussian1[] (gaussian pyramid array from image1)
gaussian2[] (gaussian pyramid array from image2)
laplacian1[] (laplacian pyramid array from image1)
laplacian2[] (laplacian pyramid array from image2)
Output:
hybrid_image (reconstructed hybrid image) Data Structure:
hybrid[] (array to save a hybrid image pyramid) Functions:
resize(target, ratio)
Algorithm:
for i from 1 to cutoff1 by 1
   hybrid[i] ← laplacian1(i)
for i from cutoff1+1 to Number of Layer by 1
   hybrid[i] ← laplacian2(i)
hybrid_image = gaussian2(Number of Layer)

for i from Number of Layer-1 to 1 by -1
   temp ← hybrid[i]
   hybrid_image ← resize(hybrid_image, 2.0)
   hybrid_image ← hybrid_image + temp

<Algorithm 2. Building a hybrid pyramid and yielding a hybrid image >

3. Extra work and discussion

I also tried to use color on each image, and here are some pros and cons for using a color.
 - Generally color does NOT help the hybrid image look clear.
 - Especially when lower frequency image has a color, it dominates whole the hybrid image
 - When lower frequency image has a color, it generally doesn't have a big effect
 - However the color could be useful in these cases:
   - When two images are sharing almost the same contour.
   - When you want to emphasize the low frequency image more.

4. Galleries

Here are few art works I generated by using this project.

Tiger + polarbear Tiger + polarbear Tiger + polarbear

< Fig 1. Tiger + Polar Bear image >

Brown bear statue + Meerkat

< Fig 2. Brown bear statue + Meerkat image >

Bin raden + Obama

< Fig 3. Osama Binraden + Obama image (no offence) >