The function "pyramids" builds an N-layer laplacian pyramid for a given image.
For each layer, we do the following steps:
1. blur the image with a 3 by 3 Gaussian filter first
2. get the laplacian layer by substracting the blurred image from the original image
3. store the layer into the matrix "laplacian"
4. shrink the blurred image into half size for the process of next layer
The last smallest image is kept and returned as output parameter "gaussian". The Laplacian pyramid is returned as output parameter "laplacian".
We are going to hybrid two images, image1 and image2. Our purpose is to get an image which looks like image1 in close distance while looks like image2 in long distance.
We implement a function called "hybridImage".
The function "hybridImage" is given the follwoing input:
gaussian1 and gaussian2 : image1 and image2's smallest image "gaussian" returned from "pyramids" function
laplacian1 and laplacian2: image1 and image2's laplacian pyramids generated by function "pyramids"
cutoff1: the number of image1's pyramid layers which will be used for hybriding
cutoff2: cutoff1 + 1, used for loop
The function "hybridImage" hybrids laplacian1(1:cutoff1,:,:), laplacian2(cutoff2:end,:,:) and "gaussian2" together, and return the result "im12". The reason is we need high frequency layers from image1 and low frequency images from image2.