Main Content

imbothat

Bottom-hat filtering

Description

J = imbothat(I,SE) performs morphological bottom-hat filtering on the grayscale or binary image I using the structuring element SE. Bottom-hat filtering computes the morphological closing of the image (using imclose) and then subtracts the original image from the result.

example

J = imbothat(I,nhood) bottom-hat filters the image I, where nhood is a matrix of 0s and 1s that specifies the structuring element neighborhood.

This syntax is equivalent to imbothat(I,strel(nhood)).

Examples

collapse all

Read image into the workspace and display it.

I = imread('pout.tif');
imshow(I)

Figure contains an axes object. The hidden axes object contains an object of type image.

Create a disk-shaped structuring element.

se = strel('disk',3);

Add the original image I to the top-hat filtered image, and then subtract the bottom-hat filtered image.

J = imsubtract(imadd(I,imtophat(I,se)),imbothat(I,se));
figure
imshow(J)

Figure contains an axes object. The hidden axes object contains an object of type image.

Input Arguments

collapse all

Input image, specified as a grayscale image or binary image of any dimension.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | logical

Structuring element, specified as a single strel object or offsetstrel object. If the image I is data type logical, the structuring element must be flat.

Structuring element neighborhood, specified as a matrix of 0s and 1s.

Example: [0 1 0; 1 1 1; 0 1 0]

Output Arguments

collapse all

Bottom-hat filtered image, returned as a grayscale image or binary image. J has the same data type as input image I.

Tips

  • If the dimensionality of the image I is greater than the dimensionality of the structuring element, then the imbothat function applies the same morphological closing to all planes along the higher dimensions.

    You can use this behavior to perform bottom-hat filtering on RGB images. Specify a 2-D structuring element for RGB images to operate on each color channel separately.

  • When you specify a structuring element neighborhood, imbothat determines the center element of nhood by floor((size(nhood)+1)/2).

Extended Capabilities

Version History

Introduced before R2006a

expand all

See Also

Functions

Objects