Blurred image generated with my_imfilter
For project 1, I was tasked with creating a matlab script which would generate hybrid images using a a custom-built filter. The actual hybrid image generation was fairly simple. As per the 2006 SIGGRAPH paper by Oliva, Torralba and Schyns, I used a guassian filter to blur images and remove their high frequencies. Once blurred images were obtained, it was trivial to obtain images with isolated high frequencies by subtracting the blurred image from the original (since the blurred image contained all low frequency content). I specified the standard deviation in pixels of a Gaussian blur in order to control the threshold between high and low frequencies. Hybrid images were then obtained by summing high frequency images with low frequency images. The gain of each frequency channel was not altered, although doing so may have resulted in more effective hybrid images.
The more difficult portion of this assignment was implementing a filtering function in matlab. The following list outlines the steps involved in my filtering function. Note that the function I wrote, my_imfilter, is heavily commented and discusses the rationale for each of these steps.
I decided against using padarray() and im2col() since I was interested in familiarizing myself with manipulating matrices at a low level within matlab.
As this was one of my first times using matlab, I had some difficulties implementing this project. I worked on this project on a couple different machines, and each machine had some unique issues. Among the challenges I encountered:
%calculating value of a filtered pixel
value = 0;
for k = 1:numFilterCols
for z = 1:numFilterRows
value = value + (filter(z,k)*image(slidingWindowOriginY+z-1, ...
slidingWindowOriginX+k-1,c));
end
end
Note that in the previous piece of code, I use the slidingWindowOrigin variables to refer to the location of the image coordinate which corresponds to
the origin of the filter. NumFilterCols refers to the number of columns in the filter, and value is the filtered value of one channel of one pixel.
*Gaussian blur standard deviation set to 5 pixels
![]() ![]() |
![]() |