Project 1: Image Filtering and Hybrid Images

The goal of this project was to implement image filtering, and then use that image filtering to implement the creation of hybrid images. For more information you can see the project spec.

Image Filtering

In order to implement image filtering we:

  1. Pad the image with zeros.
  2. Apply the filter to all possible neighborhoods.

Below you can see the algorithm that was used (padding logic extracted).


tmp = padded_im(image, filter);
[im_rows, im_cols, colors] = size(image);
[frows, fcols] = size(filter);
final = zeros(im_rows, im_cols, colors);
for c = 1:colors
    for row = 1:im_rows
        for col = 1:im_cols
            final(row,col,c) = sum(sum(filter .* tmp(row:row+frows-1, col:col+fcols-1, c)));
        end
    end
end
output = final;

Hybrid Images

To create hybrid images we follow a simple algorithm:

  1. Align two images (by hand) so that they overlap in the desired way.
  2. Get the low frequencies of one image with a Gaussian filter.
  3. Get the high frequencies of the other image (subtract off the low frequencies).
  4. Combine the two images by adding their RGB values.

Following this process yields the following images.

Low frequencies (Blur)

-->

High frequencies (Remove low frequencies)

  -   =

Combine the two

  +   =

Seen from different scales