Project 1: Image Filtering and Hybrid Images

Image Filtering

Image Filtering or Convolution is a standard image processing tool. With applications from enhancing images, to extracting information (edges and texture), all the way to being used in machine learning (Convolutional Neural networks), it is an essential concept.

Achieved through a series of matrix multiplications and additions, filtering applies a filter (a matrix), to each pixel in an image.

(the identity matrix) would cause the image to stay the same. on the other hand helps with edge detection.

In this project, a Gaussian filter was used, where the cutoff frequency determined by the standard deviation of the filter distribution.
The filtering was done independently per channel (RGB). As the filter needed the neighborhood of a pixel, the image was zero-padded to handle the corner areas. Here's the essential filtering code applied to one layer of the image-

	% Padding
	pad_h = floor(filter_h/2);
	pad_w = floor(filter_w/2);
	padded_image = padarray(image, [pad_h, pad_w]);

	% Filtering
	for r = 1 : image_h
	        for c = 1 : image_w
	            % Extracting the neighbor pixels as needed by the filter
	            neighborhood = padded_image(r : filter_h + r - 1, ...
	                                        c : filter_w + c - 1);
	            % Dot product
	            one_d_output(r, c) = sum(sum(neighborhood .* filter));
	        end
	end

Applying different filters on the image of a cat -
Identity Image Blur Image Large Blur Image
Sobel Filter Image Laplacian Image Alternative High Pass Filter Image


Hybrid Images

Hybrid Images, as the name suggests are a combination of two images. Specifically, the two images are a low-pass filtered version of one image and a high-pass filtered version of another. The actual amount of frequency to remove can be controlled.

An image of a bird and its corresponding low-pass image:

An image of a plane and its corresponding high-pass image:

Bird, Plane, or Superman ?!:




Results on some given images

Cat and Dog


Motor(bike)