MATLAB Function Reference | Search  Help Desk |
filter2 | See Also |
Two-dimensional digital filtering
Y = filter2(h,X)
Y = filter2(h,X,shape
)
Y = filter2(h,X)
filters the data in X
with the two-dimensional FIR filter in the matrix h
. It computes the result, Y
, using two-dimensional correlation, and returns the central part of the correlation that is the same size as X
.
Y = filter2(h,X,shape)
returns the part of Y
specified by the shape
parameter. shape
is a string with one of these values:
'full'
returns the full two-dimensional correlation. In this case, Y
is larger than X
.
'same'
(the default) returns the central part of the correlation. In this case, Y
is the same size as X
.
'valid'
returns only those parts of the correlation that are computed without zero-padded edges. In this case, Y
is smaller than X
.
filter2
performs linear filtering.
Given a matrix X
and a two-dimensional FIR filter h
, filter2
rotates your filter matrix 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.
conv2
Two-dimensional convolution
filter
Filter data with an infinite impulse response (IIR) or
finite impulse response (FIR) filter