Project 1: Image Filtering and Hybrid Images

In this project, I applied linear filtering to sample pairs of images and combined them to produce hybrid images. The linear filtering was performed by first padding the original image with a mirror of itself just enough to make the output image be the same dimensions as the original. Next, for each color channel, I apply the filter to sections of the padded image at a time, and take the dot product of both the matrices, and sum up all the values. This eventually constitutes the resultant image.

The hybrid image was created by applying the Gaussian filter to each image in a pair, making one low frequency and one high frequency (by subtracting a blurred image from it) and combining them.

Image filtering formula used

Looping through the entire matrix and applying the linear convolution formula constituted the main part of the image filtering process.

The formula used in the application of convolution is as follows:


Filtering logic:
for color=1:channels
    for i= 1: height
        for j= 1: width
            output(i, j, color) = sum(sum(paddedImage(i:i+filterHeight-1, j:j+filterWidth-1, color) .* filter));
        end
    end
end

Results and Examples

Results of the filters applied to cat.bmp :

The cutoff frequency while applying the Gaussian filter was adjusted for all of the following cases to reach the best hybrid image for both of them.

  1. Cutoff Frequency: 7
  2. Cutoff Frequency: 3
    Low frequency image:

    High frequency image:

    Hybrid image scales:
  3. Cutoff Frequency: 9
    Low frequency image:

    High frequency image:

    Hybrid image scales:
  4. Cutoff Frequency: 13
    Low frequency image:

    High frequency image:

    Hybrid image scales:
  5. Cutoff Frequency: 7
    Low frequency image:

    High frequency image:

    Hybrid image :

    Hybrid image scales: