Median Filter

2-D median filtering

  • Library:
  • Vision HDL Toolbox / Analysis & Enhancement

    Vision HDL Toolbox / Filtering

Description

The Median Filter block replaces each input pixel with the median value of a specified surrounding N-by-N neighborhood. The median is less sensitive to extreme values than the mean. You can use this block to remove salt-and-pepper noise from an image without significantly reducing the sharpness of the image. You can specify the neighborhood size and padding values for edges of the input image.

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

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

Select the neighborhood size, in pixels, as 3×3, 5×5, or 7×7.

Select one of these methods for padding the boundary of the input image.

  • 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 — Pad the input matrix with its mirror image.

For more information on these methods, see Edge 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 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 used to compute the median value. N is the dimension of the square region specified by the Neighborhood size parameter.

Algorithms

expand all

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.

Extended Capabilities

Introduced in R2015a