Main Content

2-D FIR Filter

2-D FIR filter on input matrix

  • 2-D FIR Filter block

Libraries:
Computer Vision Toolbox / Filtering

Description

The 2-D FIR Filter block filters a 2-D grayscale image using a 2-D finite impulse response (FIR) filter represented as a 2-D coefficient matrix or a pair of separable filter coefficient vectors.

Ports

Input

expand all

Input image, specified as a numeric matrix.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point
Complex Number Support: Yes

Filter coefficients, specified as a numeric matrix. The input to the H port must have the same data type as the input to the I port.

Dependencies

To enable this port, set the Coefficient source parameter to Input port.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point
Complex Number Support: Yes

Vertical filter coefficients, specified as a numeric vector. The input to the HV port must have the same data type as the input to the I port.

Dependencies

To enable this port, specify these parameter values.

  • Separable filter coefficientson

  • Coefficient sourceInput port

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point
Complex Number Support: Yes

Horizontal filter coefficients, specified as a numeric vector. The input to the HH port must have the same data type as the input to the I port.

Dependencies

To enable this port, specify these parameter values.

  • Separable filter coefficientson

  • Coefficient sourceInput port

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point
Complex Number Support: Yes

Pad value, specified as a numeric scalar. The input to the PVal port must have the same data type as the input to the I port.

Dependencies

To enable this port, specify these parameter values.

  • Output sizeFull or Same as input port I

  • Padding optionsConstant

  • Pad value sourceInput port

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point
Complex Number Support: Yes

Output

expand all

Filtered output image, returned as a numeric matrix of the same data type as the input image.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point

Parameters

expand all

Main

Select this parameter if your filter coefficients are separable. Using separable filter coefficients reduces the number of calculations the block must perform to compute the output. You can use isfilterseparable to check if your filter is separable and compute the vertical and horizontal filter coefficients.

Specify the source of the filter coefficients as one of these options.

  • Specify via dialog — Specify the filter coefficients using the Coefficients parameter or, if you select the Separable filter coefficients parameter, by using the Vertical coefficients (across height) and Horizontal coefficients (across width) parameters.

  • Input port — Specify the filter coefficients using the H port, or if you select the Separable filter coefficients parameter, by using the HV and HH ports.

Specify the filter coefficients as a numeric matrix.

Dependencies

To enable this parameter, specify these parameter values.

  • Separable filter coefficientsoff

  • Coefficient sourceSpecify via dialog

Specify the vertical filter coefficients as a numeric vector.

Dependencies

To enable this parameter, specify these parameter values.

  • Separable filter coefficientson

  • Coefficient sourceSpecify via dialog

Specify the horizontal filter coefficients as a numeric vector.

Dependencies

To enable this parameter, specify these parameter values.

  • Separable filter coefficientson

  • Coefficient sourceSpecify via dialog

For an input image having dimensions M-by-N and a filter having dimensions P-by-Q, specify the size of the filtered image as one of these options.

  • Full — The block uses padding to return a filtered image with full dimensions (M+P–1)-by-(N+Q–1).

  • Same as input port I — The block uses padding to return a filtered image with dimensions M-by-N, the same size as the input image.

  • Valid — The block filters the input image only where the coefficient matrix fits entirely within it without padding, and returns a filtered image with dimensions (M–P+1)-by-(N–Q+1).

Specify the padding method as one of these options.

  • Constant — Pads the input image with a constant value.

  • Replicate — Pads the input image by repeating its border values.

  • Symmetric — Pads the input image by mirror-reflecting the image across its border.

  • Circular — Pads the input image by assuming the image is periodic.

Dependencies

To enable this parameter, specify the Output size parameter as either Full or Same as input port I.

Specify the source of the padding value as one of these options.

  • Specify via dialog — Specify the pad value using the Pad value parameter.

  • Input port — Specify the pad value using the PVal port.

Dependencies

To enable this parameter, specify these parameter values.

  • Output sizeFull or Same as input port I

  • Padding optionsConstant

Specify the padding value as a numeric scalar.

Dependencies

To enable this parameter, specify these parameter values.

  • Output sizeFull or Same as input port I

  • Padding optionsConstant

  • Pad value sourceSpecify via dialog

Specify the method of filtering as Convolution or Correlation.

Data Types

For details on the fixed-point block parameters, see Specify Fixed-Point Attributes for Blocks (DSP System Toolbox).

Select this parameter to prevent the fixed-point tools from overriding the data types you specify in this block. For more information, see Lock the Output Data Type Setting (Fixed-Point Designer).

Block Characteristics

Data Types

double | fixed point | integer | single

Multidimensional Signals

no

Variable-Size Signals

yes

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced before R2006a