Project 1: Image Filtering and Hybrid Images

Image Filtering

Image Filtering is a technique of modifying or enhancing an image. It includes emphasizing certain features and involves techniques like smoothing, sharpening, edge enhancement. For this particular project, our own version of matlab function imfilter(A,h) is implemented. Several filtering techniques are tested on a cat image as shown below:

description
Original
description
Blur
description
Large Blur
description
Sobel
description
High Pass (Laplacian)
description
High Pass (Alternative)

Implementation

Matlab code snippet for filtering:

for k = 1:im_z
  for i = 1:im_x
    for j = 1:im_y
      A = (padded_img(i:i+filter_x_dim-1,j:j+filter_y_dim-1, k).*filter);
      output(i,j,k) = sum(A(:));
    end
  end
end

Code is present in code/my_imfilter.m file

Hybrid Images

A hybrid image is an image that is perceived in one of two different ways, depending on viewing distance, based on the way humans process visual inputs. Hybrid images combine the low spatial frequencies of one picture with high spatial frequencies of another picture, producing an image with an interpretation that changes with viewing distance.

Looking at picture from a short distance, one can see sharp image and high frequency picture dominates. When viewed from distance in which fine detail blurs, low frequncy image dominates.

For the project, several example pairs are tested with different cut-off frequncies for the filter to get the best optical illusion:

Dog and Cat

Cut off Frequency = 8

description
Dog (Low Frequency)
description
Cat (High Frequency)
description
Hybrid Image Scales

Marilyn and Einstein

Cut off Frequency = 3.5

description
Marilyn (Low Frequency)
description
Einstein (High Frequency)
description
Hybrid Image Scales

Fish and Submarine

Cut off Frequency = 5

description
Fish (Low Frequency)
description
Submarine (High Frequency)
description
Hybrid Image Scales

Observation: On trying fish with high frequency filter and submarine with low frequency filter, submarine image was not very clear at low frequencies, so tried with the other combination.

Motorcycle and Bicycle

Cut off Frequency (Low frequency filter) = 6

Cut off Frequency (High frequency filter) = 8

description
Motorcycle (Low Frequency)
description
Bicycle (High Frequency)
description
Hybrid Image Scales

Observation: Could not get very clear image of bicycle (at high frequency) with different cut-off frequencies. Then tried with different set of cut-off frequencies for low pass and high pass filters. Low frequency image, motorcycle, looks much better with this change.

Plane and Bird

Cut off Frequency = 8

description
Plane (Low Frequency)
description
Bird (High Frequency)
description
Hybrid Image Scales

Derek and Nutmeg

Cut off Frequency = 8

description
Derek (Low Frequency)
description
Nutmeg (High Frequency)
description
Hybrid Image Scales

Observation: Professor showed the hybrid image of Derek and Nutmeg in class. Needed to resize and rotate the images before generating the output shown above.

Conclusion

Implemented both parts of the project, i.e., Image Filtering and Hybrid Images.

In Image Filtering, implemented own version of imfilter matlab function and tested with different filtering techniques like blurring, sobel, etc.

In Hybrid Image, the three output images are presented for each pair of input images. First output image is passed through low pass filter, the second output one through high pass filter. In third output image, i.e. hybrid image scales, the leftmost image shows the high frequency image, rightmost the low frequency image and in the middle hybrid image can be observed.