Main Content

Image Filter

2-D FIR filtering

  • Image Filter block

Libraries:
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 a vector of M pixels per clock cycle to support high-frame-rate or high-resolution formats. The M value corresponds to the Number of pixels parameter of the Frame To Pixels block. 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 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 two, four, or eight pixel intensity values. For details of how to set up your model for multipixel streaming, see Filter Multipixel Video Streams.

This block does not support multicomponent streaming. To process multicomponent streams, replicate the block for each component. The pixelcontrol bus for all components is identical, so you can connect a single bus to multiple replicated blocks.

The software supports double and single data types for simulation, but not for HDL code generation.

Data Types: uint | int | fixed point | double | single

The pixelcontrol bus 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.

The software supports double and single data types 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: int | uint | fixed point | single | double

Output

expand all

Output pixel stream, returned as a scalar value representing intensity, or as a vector of two, four, or eight pixel intensity values. The dimensions and data type of the output pixel port match the dimensions and data type of the input pixel port.

The software supports double and single data types for simulation, but not for HDL code generation.

Data Types: uint | int | fixed point | double | single

The pixelcontrol bus 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

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 — Set the value of the padding pixels to mirror the edge of the image.

  • Reflection — Set the value of the padding pixels to reflect around the pixel at the edge of the image.

  • None — Exclude padding logic. The block does not set the pixels outside the image frame to any particular value. This option reduces the hardware resources used by the block and the blanking required between frames but affects the accuracy of the output pixels at the edges of the frame. To maintain pixel stream timing, the output frame is the same size as the input frame. However, to avoid using pixels calculated from undefined padding values, mask off the KernelSize/2 pixels around the edge of the frame for downstream operations. For details, see Increase Throughput by Omitting Padding.

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 horizontal line. If you specify a value that is not a power of two, the buffer uses the next largest power of two.

When you use multipixel input, this value must accommodate (Active pixels per line)/(Number of pixels) + 2.

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

Specify a rounding method for internal fixed-point calculations.

When you clear this parameter, fixed-point and integer values wrap around to zero when the value overflows what is representable with that data type. When you select this parameter, 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).

Tips

  • When you use a block with an internal line buffer inside an Enabled Subsystem (Simulink), the enable signal pattern must maintain the timing of the pixel stream, including the minimum blanking intervals. If the enable pattern corrupts the timing of the pixel stream, you might see partial output frames, corrupted pixel stream control signals, or mismatches between Simulink® and HDL simulation results. You may need to extend the blanking intervals to accommodate for cycles when the enable is low. For more information, see Configure Blanking Intervals.

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 one filter kernel for each of the M input pixels, 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

Version History

Introduced in R2015a

expand all

See Also

(Computer Vision Toolbox) | |