CS 143 / Project 1 / Image Filtering and Hybrid Images

hybrid image of a cat and a dog

This project uses image filtering to combine the high frequency signals from one image with low frequency signals from another image, creating a hybrid image. Hybrid images change interpretation as a function of viewing distance. The reason for this is that high frequency signals tend to dominate perception when available, but only low frequency signals can be seen at a distance.

You can see a hybrid image of a dog and a cat on the right. This is the result of combining the low frequency signals of the dog's image and the high frequency ones of the cat's image. Find original images and the hybrid image in different sizes below.

Image Filterng

Image filtering (convolution) is a technique that can be used to blur, sharpen images, accentuate edges, or remove noise. Specifically, image filtering uses a filter matrix to compute a weighted sum of combinations of pixels in small neighborhoods, and thus determining the pixel value of the center pixel. The core part of this filtering algorithm is presented below:


% code
% padded is the original image padded with extra pixels so that the 
% filter matrix can be applied to each pixel's neighborhood in the original image 

filtered = zeros(imrows, imcols, 3);

for i = 1:3,
    for r = 1:imrows,
        for c = 1:imcols,
            product = filter .* padded(r:(r+2*padrows), c:(c+2*padcols), i);
            filtered(r,c,i) = sum(sum(product));
        end
    end
end

Hybrid Image

The filter used in this project is the 2D Gaussian filter. For low frequency images, the result is simply the convolution of the Gaussian filter with the original image. For high frequency images, the result is the blurred high frequency image subtracted from the original image. A tunable parameter in this project is the standard deviation of the Gaussian filter used. This dictates at what frequency the cutoff between high frequency and low frequency is made. In the results section below, this parameter is specified for each result obtained through this process.

Results

Results of this project are listed below. Each result is presented with the original images in the first row, filtered images on the second, and hybrid image on the third. The number in brackets after the title of the image group indicates the standard deviation, in pixels, of the Gaussian blur used to remove the high frequencies from one image and low frequencies from another.

Cat and Dog (7)

Motorcycle and Bicycle (5)

Bird and Plane (6)

Einstein and Marilyn (5)

Submarine and Fish (6)