Project 1: Image Filtering and Hybrid Images

The goal of this homework is to write an image filtering funtion and employ it to output interesting hybrid images based off a 2006 paper by Oliva, Torralba, and Schyns titled Hybrid images. The hybrid images will appear to be two different images as a funtion of viewing distance. The main feature to this project is the implementaion of my_imfilter() in which a convolution algorithm is written to output the dot product of the filter and each filter-sized matrix of pixels throughout the image, whether it is a grayscale or color image.

Once my_imfilter() is complete, it is called from proj1.m to generate the low-frequency and high-frequency variations of the two images we wish to combine. The low frequency image simply is the image we obtain from calling my_imfilter() while the high frequency image is the my_imfilter() output subtracted from the original image so that the low frequencies are removed. Finally, we just add these two images together and we have our hybrid image.

Portion of im_filter() code


%Convolution Algorithm used in my_imfilter()
for c = 1 : chan
    for i = 1 : m
        for j = 1 : n
            output(i, j, c) = sum(sum(padImage(i : i+fRows-1, j : j+fCols-1, c) .* filter));
        end
    end
end

Examples of Results