Laplacian Image Pyramids
The hypothesis of the project: having a pyramid of Gaussian and Laplacian filtered images
of decreasing sizes, it is possible to reconstruct from the smallest filtered image up to
original image size, substituting part of the missing frequency from another image's pyramid,
thus producing a hybrid image.
Idea of hybrid images comes from the fact that images can be separated (filtered) to keep only their high or low
frequencies. In Fourier domain low frequency is obtained using Gaussian filter, which blurs the image, leaving it
without high frequency details. Laplacian filter is a compliment to Gaussian and picks up those features that are
not in Gaussian output. Gaussian and Laplacian filtered images being summed up, produce the original image.
The algorithm of the program:
two images are loaded into memory
transformed to grey scale
aligned relative to each other
number of layers in Gaussian pyramid is set to a constant
pyramids function is called for both images
calculate a matrix of Gaussian filter (used in project is 5x5 with omega value 8.0)
for each layer:
apply Gaussian filter to image
get Laplacian filtered image by subtracting Gaussian filtered image from original
reduce size of image with both frequencies by 2 (see image 1)
set last level of Laplacian pyramid equal to last level of Gaussian to preserve low frequencies
output of pyramids function is Laplacian and Gaussian pyramid for each image (see image 2)
setting the cutoff value (the bigger the value the less low frequency and more high frequency is in the final hybrid)
hybridImage function is called (parameters are two Laplacian pyramids and cutoff value)
start creating a hybrid pyramid
for levels up to cutoff copy first low frequencies from first image
after cutoff add high frequencies from second image
when hybrid pyramid is filled with filtered images for every layer do:
resize result image (we start with the lowest level) to size of current Laplacian layer
sum them into a resulting image
result contains all layers resized and combined
the image is shown (see result images 3 and 4)
if needed croped and rescaled
Image 1. Pyramid of layers of images of decreasing sizes Image 2. Gaussian and Laplacian pyramids combined
Results
Image 3. Cutoff = 2. A lot of high frequency details from one source and a low frequency canvas from another
Image 4. Cutoff = 1. Image looks sharper with less high frequency detailes from second source
Source of inspiration
Image 5. Excited Federer
Image 6.Angry tiger
Results on provided images
|