CS 143 / Project 1 / Image Filtering and Hybrid Images

In this project, I'll be implementing MATLAB functions for image filtering and creating hybrid images using a simplified versiion of the SIGGRAPH 2006 paperby Oliva, Torralba, and Schyns.

Part I: Image Filtering

my_imfilter

To perform image filtering. Usage is same with MATLAB function imfilter
Syntax
output = my_imfilter(im, filter, option)
Description
output = my_imfilter(im, filter, option) filters image im with matrix filter. The image can be color or gray.
Boundary Options
Option Description
'X' Outside the bounds of the image are implicitly assumed to have the zero value. When no boundary option is specified, my_imfilter uses this option.
'symmetric' Outside the bounds of the image are computed by mirror-reflecting the image across the image border
Examples


test_image = im2single(imread('../data/cat.bmp'));
test_image = imresize(test_image, 0.7, 'bilinear'); %resizing to speed up testing
sobel_filter = [-1 0 1; -2 0 2; -1 0 1]; 
sobel_image = my_imfilter(test_image, sobel_filter);

     

Other examples
Small blur with a box filter Identity filter
Large Blur Laplacian filter

Part II: Hybrid Image

The SIGGRAPH 2006 paper uses two cut-off frequencies to get images in high frequency domain and low frequency domain, while in our case we only use single cut-off frequencies to deal with this. Namely, we use the code:

filter = fspecial('Gaussian', cutoff_frequency*4+1, cutoff_frequency);
low_frequencies = my_imfilter(image1,filter);
high_frequencies = image2 - my_imfilter(image2,filter);
hybrid_image = low_frequencies + high_frequencies;

By altering cutoff frequency, we can manually choose the one that produce best performance.

We write proj1.m as a function which takes the imname_1 and imname_2 as the name of the images that will be filtered with low-pass and high-pass filter respectively, and cutoff_frequency. We included the codes/results below.


proj1('dog.bmp', 'cat.bmp', 7);
proj1('marilyn.bmp', 'einstein.bmp',3);
proj1('motorcycle.bmp', 'bicycle.bmp',4);
proj1('bird.bmp', 'plane.bmp',3);
proj1('fish.bmp', 'submarine.bmp',4.5);

Results in a table