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.
% 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
Identity Image | Blur Image | Large Blur Image |
Sobel Filter Image | Laplacian Image | Alternative High Pass Filter Image |
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: