Image Filter

2-D FIR filtering

  • Library:
  • Vision HDL Toolbox / Filtering

Description

The Image Filter block performs two-dimensional finite impulse response (FIR) filtering on a pixel stream and supports the use of programmable filter coefficients.

Ports

This block uses a streaming pixel interface with a bus for frame control signals. This interface enables the block to operate independently of image size and format. The pixel ports on this block support single pixel streaming or multipixel streaming. Single pixel streaming accepts and returns a single pixel value each clock cycle. Multipixel streaming accepts and returns 4 or 8 pixels per clock cycle to support high-frame-rate or high-resolution formats. Along with the pixel, the block accepts and returns a pixelcontrol bus that contains five control signals. The control signals indicate the validity of each pixel and their location in the frame. For multipixel streaming, one set of control signals applies to all four or eight pixels in the vector. To convert a frame (pixel matrix) into a serial pixel stream and control signals, use the Frame To Pixels block. For a full description of the interface, see Streaming Pixel Interface.

Input

expand all

This block supports single pixel streaming or multipixel streaming. For single pixel streaming, specify a single input pixel as a scalar intensity value. For multipixel streaming, specify a vector of four or eight pixel intensity values. For details of how to set up your model for multipixel streaming, see Filter Multipixel Video Streams.

double and single data types are supported for simulation, but not for HDL code generation.

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

Control signals associated with the pixel stream, specified as a pixelcontrol bus that contains five signals. The signals describe the validity of the pixel and its location in the frame. For more information, see Pixel Control Bus.

For multipixel streaming, each vector of pixel values has one set of control signals. Because the vector has only one valid signal, the pixels in the vector must be either all valid or all invalid. The hStart and vStart signals apply to the pixel with the lowest index in the vector. The hEnd and vEnd signals apply to the pixel with the highest index in the vector.

Data Types: bus

Specify the filter coefficients as a 2-D matrix of numeric values. Each dimension of the matrix must have at least 2 elements, but no more than 64 elements.

double and single data types are supported for simulation but not for HDL code generation.

The block samples the values from the coeff port only at the start of a frame and ignores any changes within a frame.

Dependencies

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

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

Output

expand all

This block supports single pixel streaming or multipixel streaming. When using single pixel streaming, the block returns a single input pixel as a scalar intensity value. When using multipixel streaming, the block returns a vector of intensity values. This vector is the same size as the input pixel vector. For details of how to set up your model for multipixel streaming, see Filter Multipixel Video Streams.

The output pixel data type is the same as the data type of the input pixels.

double and single data types are supported for simulation, but not for HDL code generation.

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

Control signals associated with the pixel stream, specified as a pixelcontrol bus that contains five signals. The signals describe the validity of the pixel and its location in the frame. For more information, see Pixel Control Bus.

For multipixel streaming, each vector of pixel values has one set of control signals. Because the vector has only one valid signal, the pixels in the vector are either all valid or all invalid. The hStart and vStart signals apply to the pixel with the lowest index in the vector. The hEnd and vEnd signals apply to the pixel with the highest index in the vector.

Data Types: bus

Parameters

expand all

Main

Select the source for specifying the filter coefficients.

  • Property (default) — Use this value to specify filter coefficients using the Filter coefficients parameter.

  • Input port — Use this value to specify filter coefficients through the coeff input port.

Specify the filter coefficients as a matrix. Each dimension of the matrix must have at least 2 elements, but no more than 64 elements.

Dependencies

To enable this parameter, set the Filter coefficients source parameter to Property.

Select one of these methods for padding the boundary of the input image. For more information about these methods, see Edge Padding.

  • Constant — Interpret pixels outside the image frame as having a constant value.

  • Replicate — Repeat the value of pixels at the edge of the image.

  • Symmetric — Add the padding pixels to mirror the edge of the image.

Specify an integer to pad the boundary of the input image. The block casts this value to the same data type as the input pixel.

Dependencies

To enable this parameter, set the Padding method parameter to Constant.

Size of the line memory buffer, specified as a positive integer. Choose a power of two that accommodates the number of active pixels in a single horizontal line.

If you specify a value that is not a power of two, the block uses the next largest power of two. The block allocates (N — 1)-by-Line buffer size memory locations to store the pixels. N represents the rows of the coefficient matrix.

Data Types

Select the rounding mode for internal fixed-point calculations as Floor, Ceiling, Convergent, Nearest, Round, and Zero. For more information about rounding modes, see Rounding Modes (DSP System Toolbox).

When this parameter is off, fixed-point and integer values wrap around to 0 when the value overflows what is representable with that data type. When this parameter is on, the value saturates at the maximum representable value.

Select the method for determining the data type of the filter coefficients.

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the data type of the Coefficients parameter. For details, see Specify Data Types Using Data Type Assistant (Simulink).

When converting the coefficients to the specified data type, the block rounds to the nearest representable value and saturates to the maximum value if the value exceeds the maximum value representable with the data type.

Dependencies

To enable this parameter, set the Filter coefficients source parameter to Property.

Select the method for determining the data type of the output pixel.

Click the Show data type assistant button to display the Data Type Assistant, which helps you to set the data type of the Output parameter. For details, see Specify Data Types Using Data Type Assistant (Simulink).

Select this parameter to lock all data type settings of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor. For more information, see Lock the Output Data Type Setting (Fixed-Point Designer).

Algorithms

expand all

The block implements the 2-D FIR filter with a fully pipelined architecture. Each multiplier has two pipeline stages on each input and two pipeline stages on each output. The adder is a pipelined tree structure. HDL code generation uses symmetric, unity, or zero-value coefficients to reduce the number of multipliers.

When you use multipixel streaming, the block uses a single line memory and implements NumberOfPixels filter kernels in parallel. This increase in hardware resources is a trade off for increasing throughput compared to single-pixel streaming.

When you provide coefficients using the Filter coefficients parameter, you can optimize the multipliers for HDL code generation by using a canonical signed digit (CSD) representation or factored CSD representation. To use a CSD of factored CSD representation, right-click the block, select HDL Code > HDL Block Properties, and set the ConstMultiplierOptimization parameter to csd or fcsd.

When you provide coefficients using the coeff port, the latency depends on the size of the filter coefficients. For an N-by-M coefficient matrix provided using the coeff port, the block generates NxM multipliers.

Extended Capabilities

Introduced in R2015a