| Video and Image Processing Blockset™ | ![]() |
Morphological Operations

The Top-hat block performs top-hat filtering on an intensity or binary image using a predefined neighborhood or structuring element. Top-hat filtering is the equivalent of subtracting the result of performing a morphological opening operation on the input image from the input image itself. This block uses flat structuring elements only.
| Port | Input/Output | Supported Data Types | Complex Values Supported |
|---|---|---|---|
I | Vector or matrix of intensity values |
| No |
Nhood | Matrix or vector of 1s and 0s that represents the neighborhood values | Boolean | No |
Output | Scalar, vector, or matrix that represents the filtered image | Same as I port | No |
If your input image is a binary image, for the Input image type parameter, select Binary. If your input image is an intensity image, select Intensity.
Use the Neighborhood or structuring element source parameter to specify how to enter your neighborhood or structuring element values. If you select Specify via dialog, the Neighborhood or structuring element parameter appears in the dialog box. If you select Input port, the Nhood port appears on the block. Use this port to enter your neighborhood values as a matrix or vector of 1s and 0s. Choose your structuring element so that it matches the shapes you want to remove from your image. You can only specify a it using the dialog box.
Use the Neighborhood or structuring element parameter to define the region the block moves throughout the image. Specify a neighborhood by entering a matrix or vector of 1s and 0s. Specify a structuring element with the strel function from the Image Processing Toolbox. If the structuring element is decomposable into smaller elements, the block executes at higher speeds due to the use of a more efficient algorithm.
The Top-hat dialog box appears as shown in the following figure.

If your input image is a binary image, select Binary. If your input image is an intensity image, select Intensity.
Specify how to enter your neighborhood or structuring element values. Select Specify via dialog to enter the values in the dialog box. Select Input port to use the Nhood port to specify the neighborhood values. You can only specify a structuring element using the dialog box.
If you are specifying a neighborhood, this parameter must be a matrix or vector of 1s and 0s. If you are specifying a structuring element, use the strel function from the Image Processing Toolbox. This parameter is visible if, for the Neighborhood or structuring element source parameter, you select Specify via dialog.
Video and Image Processing Blockset software | |
Video and Image Processing Blockset software | |
Video and Image Processing Blockset software | |
Video and Image Processing Blockset software | |
Video and Image Processing Blockset software | |
Video and Image Processing Blockset software | |
Image Processing Toolbox software | |
Image Processing Toolbox software |
![]() | To Video Display | Trace Boundaries | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |