Image of a bicycle filtered through a laplacian filter.
The purpose of the project was to implement a simplified version of the imfilter() function in Matlab, called my_imfilter(), to generate hybrid images. The filter was supposed to conform to the following specification:
To go about making such a filter, linear image filtering was studied. Basically, an image filter makes a new image in which each pixel of the new image is equal to the sum of all elements of a matrix; this matrix is the result of multiplying 2 matrices: the filter and a patch of the original image that is centered on by the filter. It is worth mentioning that the multiplication is not a matrix multiplication, but rather an element-by-element multiplication.
Making that filter is all well and good, but what happens at the edges? You can't center a 11X11 filter on the boundary of an image! Therefore, one solution is to pad the edges with 0s, but that wouldn't be ideal because the edges would appear black and we would lose content. Therefore, instead, we use only part of the filter at the edges, conforming to how much of the filter we can center at the particular boundary.
%Low pass one image
low_frequencies = my_imfilter(image1, filter);
%High pass the other
high_frequencies = image2 - my_imfilter(image2, filter);
%Now combine them
hybrid_image = low_frequencies + high_frequencies;
![]() ![]() ![]() |
![]() ![]() ![]() |
Above, the first image in each row is the high passed version of a photo. The second image in each row is the low passed version of another photo. The third larger photo is the hybrid image, and the subsequent images are scaled down versions of the hybrid image to see the effect of the hybridization. As we can see clearly, at small distances, the high frequencies dominate, however, at large distances, low frequencies dominate.