Main Content

Grayscale Closing

Morphological closing of grayscale pixel data

  • Grayscale Closing block

Libraries:
Vision HDL Toolbox / Morphological Operations

Description

The Grayscale Closing block performs morphological dilation followed by morphological erosion by using the same neighborhood for both calculations. The block operates on a stream of pixel intensity values. You can specify a neighborhood or structuring element of up to 32-by-32 pixels.

For line, square, or rectangle structuring elements more than 8 pixels wide, the block uses the Van Herk algorithm to find the maximum and minimum pixel values. For structuring elements less than 8 pixels wide, or that contain zero elements, the block implements a pipelined comparison tree to find the maximum and minimum pixel values.

Ports

This block uses a streaming pixel interface with a pixelcontrol bus for frame control signals. This interface enables the block to operate independently of image size and format. All Vision HDL Toolbox™ blocks use the same streaming interface. The block accepts and returns a scalar pixel value and a bus that contains five control signals. The control signals indicate the validity of each pixel and its location in the frame. 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

Single image pixel in a pixel stream, specified as an unsigned integer scalar that represents grayscale intensity.

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

Data Types: uint8 | uint16 | uint32 | uint64 | double | single | fi(0,N,0)

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.

Data Types: bus

Output

expand all

Single output pixel transformed by a morphological operation, returned as a scalar value.

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

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.

Data Types: bus

Parameters

expand all

Pixel neighborhood, specified as a vector or matrix of binary values.

The block supports flat neighborhoods of up to 32-by-32 pixels. To use a structuring element, set the Neighborhood parameter to getnhood (Image Processing Toolbox)(strel (Image Processing Toolbox)(shape)), where shape is specified by the input arguments to the strel (Image Processing Toolbox) function. The minimum neighborhood size is a 2-by-2 matrix, or a 2-by-1 column vector. If the neighborhood is a row vector, it must be at least 8 columns wide and contain no zeros.

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.

The block allocates (n – 1)-by-Line buffer size memory locations to store the pixels, where n is the number of lines in the Neighborhood parameter value.

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 closing algorithm is morphological dilation followed by morphological erosion. For the respective kernel architectures, see the Grayscale Dilation and Grayscale Erosion reference pages.

The block pads the image with zeros for the dilation operation and with ones for the erosion operation. For more information, see Edge Padding.

Extended Capabilities

Version History

Introduced in R2016a

expand all

See Also

| | (Computer Vision Toolbox) | |

Topics