Image Processing Toolbox
  Go to function:
    Search    Help Desk 
filter2    Examples   See Also

Perform two-dimensional linear filtering

Syntax

Description

B = filter2(h,A) filters the data in A with the two-dimensional FIR filter in the matrix h. It computes the result, B, using two-dimensional correlation, and returns the central part of the correlation that is the same size as A.

B = filter2(h,A,shape) returns the part of B specified by the shape parameter. shape is a string with one of these values:

Class Support

The matrix inputs to filter2 can be of class double or of any integer class. The output matrix B is of class double.

Remarks

Two-dimensional correlation is equivalent to two-dimensional convolution with the filter matrix rotated 180 degrees. See the Algorithm section for more information about how filter2 performs linear filtering.

filter2 is a function in MATLAB.

Example

Algorithm

Given an image A and a two-dimensional FIR filter h, filter2 rotates your filter matrix (the computational molecule) 180 degrees to create a convolution kernel. It then calls conv2, the two-dimensional convolution function, to implement the filtering operation.

filter2 uses conv2 to compute the full two-dimensional convolution of the FIR filter with the input matrix. By default, filter2 then extracts the central part of the convolution that is the same size as the input matrix, and returns this as the result. If the shape parameter specifies an alternate part of the convolution for the result, filter2 returns the appropriate part.

See Also

conv2, roifilt2



[ Previous | Help Desk | Next ]