Project 1: Image Filtering and Hybrid Images

Original cat image.

In this project, we fisrtly implemented an image filtering function my_imfilter(), then test it with a cat image through six different filters.

  1. Identity filter
  2. Small blur filter
  3. Large blur filter
  4. Oriented filter (Sobel Operator)
  5. High pass filter (Discrete Laplacian)
  6. High pass "filter" alternative

Secondly, we generate a hybrid image, which is the sum of a low-pass filtered version of the one image and a high-pass filtered version of a second image. Here two images are filtered by our function my_imfilter().

Filtering function

The filtering function my_imfilter() is implemented as follows: Pad the input image with zeros, pointwise multiplication and summation, return a filtered image which is the same resolution as the input image. Note: This function supports both grayscale and color images, and supports arbitrary shaped filters, as long as both dimensions are odd.

Test results

The following images show the results of my_imfilter(image, filter), where image = original cat image, and filter = identity filter, blur filter, large blur filter, Sober opertor, discrete Laplacian, and high-pass filter.

Hybrid images

To generate hybrid images, we use Gaussian filter as a low-pass filter, and discrete Laplacian can be utilized as a high-pass filter, or we can simply have a high-pass filtered image by subtracting the low-pass filtered image from th original image.

Results

The following images show the results of hybrid images, including low-frequency, high-frequency, hybrid images and visualization of a hybrid image by progressively downsampling the image and concatenating all of the images together. Low frequency images are generated by Gaussian filter, and high frequency images are generated by discrete Laplacian or simply subtracting the low frequency image from the original image.

In the next, we try to generate the high frequency image using FFT and the convolution theorem.

Here, we build a hybrid image on gray scale images. The low frequency image is generated by using FFT and the convolution theorem, and the high frequency image is obtained through discrete Laplacian. After experiments, we found that FFT is much faster than filtering spatial domain. The reason might be that filtering involves many iteration.