vision.ImageFilter System object

Package: vision

Perform 2-D FIR filtering of input matrix

Description

The ImageFilter object performs 2-D FIR filtering of input matrix.

Construction

H = vision.ImageFilter returns a System object, H. This object performs two-dimensional FIR filtering of an input matrix using the specified filter coefficient matrix.

H = vision.ImageFilter(Name,Value) returns an image filter System object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1, Value1,...,NameN,ValueN).

Code Generation Support
Supports MATLAB® Function block: Yes
System Objects in MATLAB Code Generation.
Code Generation Support, Usage Notes, and Limitations.

Properties

SeparableCoefficients

Set to true if filter coefficients are separable

Using separable filter coefficients reduces the amount of calculations the object must perform to compute the output. The function isfilterseparable can be used to check filter separability. The default is false.

CoefficientsSource

Source of filter coefficients

Indicate how to specify the filter coefficients as one of Property | Input port. The default is Property.

Coefficients

Filter coefficients

Specify the filter coefficients as a real or complex-valued matrix. This property applies when you set the SeparableCoefficients property to false and the CoefficientsSource property to Property. The default is [1 0; 0 -1].

VerticalCoefficients

Vertical filter coefficients for the separable filter

Specify the vertical filter coefficients for the separable filter as a vector. This property applies when you set the SeparableCoefficients property to true and the CoefficientsSource property to Property. The default is [4 0].

HorizontalCoefficients

Horizontal filter coefficients for the separable filter

Specify the horizontal filter coefficients for the separable filter as a vector. This property applies when you set the SeparableCoefficients property to true and the CoefficientsSource property to Property. The default is [4 0].

OutputSize

Output size as full, valid or same as input image size

Specify how to control the size of the output as one of Full | Same as first input | Valid. The default is Full. When you set this property to Full, the object outputs the image dimensions in the following way:

output rows = input rows + filter coefficient rows –1
output columns = input columns + filter coefficient columns – 1

When you set this property to Same as first input, the object outputs the same dimensions as the input image.

When you set this property to Valid, the object filters the input image only where the coefficient matrix fits entirely within it, and no padding is required. In this case, the dimensions of the output image are as follows:

output rows = input rows - filter coefficient rows –1
output columns = input columns - filter coefficient columns –1

PaddingMethod

How to pad boundary of input matrix

Specify how to pad the boundary of input matrix as one of Constant | Replicate | Symmetric, | Circular. The default is Constant. Set this property to one of the following:

  • Constant to pad the input matrix with a constant value

  • Replicate to pad the input matrix by repeating its border values

  • Symmetric to pad the input matrix with its mirror image

  • Circular to pad the input matrix using a circular repetition of its elements

This property applies when you set the OutputSize property to Full or to Same as first input.

PaddingValueSource

Source of padding value

Specify how to define the constant boundary value as one of Property | Input port. This property applies when you set the PaddingMethod property to Constant. The default is Property.

PaddingValue

Constant value with which to pad matrix

Specify a constant value with which to pad the input matrix. This property applies when you set the PaddingMethod property to Constant and the PaddingValueSource property to Property. The default is 0. This property is tunable.

Method

Method for filtering input matrix

Specify the method by which the object filters the input matrix as one of Convolution | Correlation. The default is Convolution.

 Fixed-Point Properties

Methods

cloneCreate image filter object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs from step method
isLockedLocked status for input attributes and nontunable properties
release Allow property value and input characteristics changes
stepFilter input image

Examples

Filter an image to enhance the edges of 45 degree

 img = im2single(rgb2gray(imread('peppers.png')));
 hfir2d = vision.ImageFilter;
 hfir2d.Coefficients = [1 0; 0 -.5];
 fImg = step(hfir2d, img);
 subplot(2,1,1);imshow(img);title('Original image')
 subplot(2,1,2);imshow(fImg);title('Filtered image')

Algorithms

This object implements the algorithm, inputs, and outputs described on the 2-D FIR Filter block reference page. The object properties correspond to the block parameters.

Was this topic helpful?