Project 1: Image Filtering and Hybrid Images

Image after padding with reflection.

This project consisted of implementing image filtering, and then using that implementation to create hybrid images.

Image Filtering

Image filtering was implemented by first splitting an image into separate channels, which were then filtered by convolving a given kernel across the pixels. The corner cases were taken care of by padding the image with a reflection of the edge.

Hybrid Images

Hybrid images were created by combining the high-pass filtered version of one image and the low-pass filtered version of another. The low-pass filter was implemented as a Gaussian blur, while the high-pass filter was implemented as the original image with the blurred image subtracted. These filters utilized the image filtering implementation that was described earlier.

The sigma and size parameters of the Gaussian was changed until the hybrid image could be interpreted as either image when viewed at different distances. In the code, the cutoff_frequency was used to modify these values. The sigma parameter is equal to the cutoff frequency, and the size of the kernel equal to the cutoff_frequency*4+1.


filter = fspecial('Gaussian', cutoff_frequency*4+1, cutoff_frequency);

The original pictures are shown below.

The high-frequencies are then kept from one image, and the low-frequencies from the other.

Then the two filtered images are added together to form the hybrid image. Viewing the image at different distances produces different interpretations of the image.

Here, more hybrid images are shown. As long as the images look have a similar shape and are well aligned, hybrid images can be created.

Results in a table

As seen from the results, merging to images to produce a hybrid image produces better results when the color and size of the subjects of the images are similar. The Einstein/Marliyn hybrid image and the bicycle/motorcycle hybrid image both look like only one object when up close and the other when far away, due to their similar shape and colors. However, in the fish/submarine and bird/plane hybrid images, the second object can still be distinguished when viewed up close due to them being less aligned and differently colored.