This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

vision.MorphologicalTopHat System object

Package: vision

Top-hat filtering on image


    Note:   The vision.MorphologicalTopHat System object will be removed in a future release. Use the imtophat function with equivalent functionality instead.

    Note:   Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


H = vision.MorphologicalTopHat returns a top–hat filtering object, H, that performs top-hat filtering on an intensity or binary image using a predefined neighborhood or structuring element.

H = vision.MorphologicalTopHat(Name,Value) returns a top-hat filtering object, H, with each property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1, Value1,...,NameN,ValueN).

Code Generation Support
Supports MATLAB® Function block: Yes
System Objects in MATLAB Code Generation.
Code Generation Support, Usage Notes, and Limitations.



Specify type of input image or video stream

Specify the type of input image or video stream as Intensity or Binary. The default is Intensity.


Source of neighborhood values

Specify how to enter neighborhood or structuring element values as Property or Input port. If set to Property, use the Neighborhood property to specify the neighborhood or structuring element values. Otherwise, specify the neighborhood using an input to the step method. Note that structuring elements can only be specified using the Neighborhood property. You cannot use the structuring elements as an input to the step method. The default is Property.


Neighborhood or structuring element values

This property applies only when you set the NeighborhoodSource property to Property. If specifying a neighborhood, this property must be a matrix or vector of 1s and 0s. If specifying a structuring element, use the strel function. The default is strel('square',4).


cloneCreate morphological top hat filter with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs from step method
isLockedLocked status for input attributes and non-tunable properties
release Allow property value and input characteristics changes
stepPerform top-hat filtering on input image


Perform top-hat filtering to correct uneven illumination.

 I = im2single(imread('rice.png'));
 htop = vision.MorphologicalTopHat('Neighborhood',strel('disk', 12));
% Improve contrast of output image
 		hc = vision.ContrastAdjuster;  J = step(htop,I);
		J = step(hc,J);

 subplot(1,2,1),imshow(I); title('Original image');
 title('Top-hat filtered image'); 


This object implements the algorithm, inputs, and outputs described on the Top-hat block reference page. The object properties correspond to the block parameters.

Introduced in R2012a

Was this topic helpful?