# filter2

## Purpose

Two-dimensional digital filtering.

## Synopsis

    Y = filter2(B,X)
    Y = filter2(B,X,'shape')

## Description

`Y = filter2(B,X)` filters the data in `X` with the two-dimensional FIR filter in the matrix `B`. The result, `Y`, is computed using two-dimensional convolution and is the same size as `X`.

`Y = filter2(B,X,'shape')` returns `Y` computed via two-dimensional convolution with size specified by `shape`:

- `same` returns the central part of the convolution that is the same size as `X` (default).
- `full` returns the full two-dimensional convolution, `size(Y)` > `size(X)`.
- `valid` returns only those parts of the convolution that are computed without the zero-padded edges, `size(Y)` < `size(X)`.

  ## Algorithm

  `filter2` uses `conv2` to compute the full two-dimensional convolution of the FIR filter with the input matrix. By default, `filter2` extracts and returns the central part of the convolution that is the same size as the input matrix. Use the `shape` parameter to specify an alternate part of the convolution for return.

  ## See Also

      conv2, filter

  (c) Copyright 1994 by The MathWorks, Inc.