Check the deadline on cssubmit.
The aim of this laboratory session is to introduce you to hybrid images and how to generate them in MATLAB. Hybrid images are images with two interpretations, which change as a function of the viewing distance. Based on the multiscale processing of images by the human visual system, we can synthesize a hybrid image by combining one input image A that has been blurred by a low-pass filter and another input image B that has been sharpened by a high-pass filter. When the resultant image is viewed at a close-up distance, the sharpened image dominates and we see B. When the resultant image is viewed from afar, the blurred image reveals and we see A. This is illustrated in Figure 2 of the SIGGRAPH 2006 paper by Oliva et al :
(Extracted from Figure 2 of Oliva et al )
 A. Oliva, A. Torralba, P.G. Schyns (2006). "Hybrid Images". ACM Transactions on Graphics, ACM Siggraph, 25-3, 527-530.
To create a hybrid image from two given input images (of the same dimension),
you need to perform the smoothing and sharpening operations in the frequency
domain. For the 1D case, a low-pass filter
(as a function of frequency) can be constructed using the following
A few 1D low-pass filters with different c and
n values are given in the
Note: This is a filter defined directly in the frequency domain. Do not confuse it with a Gaussian filter (for image smoothing in the spatial domain) where a broad profile means a larger standard deviation and more smoothing.
A high-pass filter fhp can be defined as follows:
You can get low and high pass filter code from Professor Kovesi's website. You can use these functions to create 2D low-pass and high-pass filters. Download these functions and ensure that you understand how to call them. Note that the filters returned by these two functions are defined with the low frequency values at the beginning (i.e., corners) and end of the array. This conforms with the Fourier transform returned by Matlab's fft2 functions. A rule of thumb is therefore to stick to this convention and only use fftshift to swap the quadrants when you need to view the Fourier spectrum.
Sample image pairs
Some sample image pairs that you can use for your experiments are given below. Both images in each pair have the same dimension and have been aligned. Feel free to use your own image pairs. If you do so, include your images in your submission to cssubmit.
An example for generating a hybrid image is given below. The input image pair
is the mouse.png and cat.png files. As these images are
colour images, you should first convert them into greyscale, giving
Design your low-pass filters and high-pass filters by selecting appropriate values for c and n. Ensure that the two filters do not cover a large common range of frequency values (see Figure 5(a) and (b) of reference  above and the related discussion there).
After applying your filters to the two images, it is a good practice to inspect the output smoothed and sharpened images before composing the hybrid image. For instance, your smoothed and sharpened images might look like this:
When the Fourier transforms of these two images are added and then inverse FFT back to the spatial domain, what you get is the desired hybrid image, which might look like:
You can try constructing colour (rather than greyscale) hybrid images if you have the time. However, greyscale images are sufficient for the exercises here.
Submission RequirementsSubmit to cssubmit the following:
Apart from the lowpassfilter.m and highpassfilter.m files that you download from Assoc. Prof. Kovesi's website, other functions from his website that you use for this lab sheet must be included in your submission. We will test run your test1.m and test2.m files in the marking process. It is therefore important that your submission is complete.
Your Matlab code should be commented (but not over-commented) and indented for readability (Hint: Use the Matlab Editor to help you indent your code).