imfilter

Applies a linear filter on image data.

Syntax

h = imfilter(data, filter)

h = imfilter(data, filter, method)

Inputs

data
Data on which linear filtering is applied. Must be a real, non-sparse 2 dimensional or multi-dimensional matrix.
Type: matrix
filter
Linear filter. Must be a real, non-sparse 2 dimensional matrix.
Type: matrix
method
Method used to apply the filtering. Valid values are 'corr'(default) and 'conv'. 'corr' applies the filter using correlation and 'conv' applies the filter using convolution.
Type: string

Outputs

h
Filtered image data.
Type: matrix

Example

Apply a Gaussian filter using convolution:
close all;
linearfilter = fspecial('gaussian', 3, 0.5);
handle = imreadcv('imfilter_1.png');
data = getcv(handle);
filteredimage = imfilter(data, linearfilter, 'conv');

figure(1);
imshowcv(data);

figure(2);
imshowcv(filteredimage);
Figure 1. Original image


Figure 2. Filtered image