Project 1: Image Filtering and Hybrid Images

dog-cat hybrid image

Made with cutoff frequency 7

  1. Project Intro.
  2. Code.
  3. Filters
  4. Results
  5. Conclusion

Project intro

This is the writeup for CS 4476, Computer Vision, project 1. This project is on image filtering and creating hybrid images. The main point is to implement an algorithm to filter images, and perform hybridization based on the SIGGARTH method described in a 2006 paper. The hybridization merges the high and low frequencies of two different images, creating hybrid images that looks like one or the other at distance or up close. The filters implementations shows the results for sobel, gaussian blurs, a high pass, a large blur, identity, and the laplacian filters.

Code

This is the code for the my_imfilter implementation. As a dot product multiplication of the filter and the image, it's a fairly straightforward iteration over the rows, columns, and layers of the image.


%set up the image to start operating on
output = image;
%sizes of the filter
[m, n] = size(filter);
%creating the padded(filled with zeroes) array from which the dot product
%of the filter will take place
padded_image = padarray(image,[floor(m/2), floor(n/2)]);
%getting the sizes of the image.
[row, col, layer] = size(image);

%this is where we begin to iterate over the entire image.
%this is where the filter dot products/multiplies and saves every value
%into the output image in every layer/column/row. Output gets returned as
%the final image.
for aLayer = 1: layer
    for aColumn = 1: col
        for aRow = 1: row
            value = sum(sum(padded_image(aRow:(aRow+m-1), aColumn:(aColumn+n-1), aLayer).*filter));
            output(aRow, aColumn, aLayer) = value;
        end
    end
end

This is the code for the filter implementations, with the commenting removed. They filter the image to get the low and high frequencies of two different images. Combining them creates the hybrid image with the close/far different image phenomenon due to how the eyes work.


	low_frequencies = my_imfilter(image1, filter);
	low_frequencies2 = my_imfilter(image2, filter);
	high_frequencies = image2 - low_frequencies2;

	hybrid_image = low_frequencies + high_frequencies;
	

Filters

The following represent the results of using the proj1_test_filtering code.

The filters are, respectively, blur, high pass, identity, laplacian, large blur, and sobel.

Results

For the following tables, the first image represents the high frequencies, the second the hybrid, the third the scalings, and the last image represents the low frequencies. Additionally, the [image1][image2] captions describe which image was high frequency and which was low. The first image is high frequency, the second low. I varied the frequencies for different images to test the results.

Dog cat hybrid. Cutoff frequency 7

Cat dog hybrid. Cutoff frequency 7

Einstein Marilyn hybrid. Cutoff frequency 6

Marilyn Einstein hybrid. Cutoff frequency 6

Bicycle motocycle hybrid. Cutoff frequency 5

Conclusion

The marilyn/einstein hybrids could have been better- maybe a lower frequency. I was particularly able to notice the hybrid phenomenon with the bike/motorcycle scaled images. The cutoff frequencies seem to dictate how well that phenomenon appears.