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.


Bottom-hat filtering


IM2 = imbothat(IM,SE)
IM2 = imbothat(IM,NHOOD)
gpuarrayIM2 = imbothat(gpuarrayIM,___)


IM2 = imbothat(IM,SE) performs morphological bottom-hat filtering on the grayscale or binary input image, IM, returning the filtered image, IM2. SE is a structuring element returned by the strel function. SE must be a single structuring element object, not an array containing multiple structuring element objects.

IM2 = imbothat(IM,NHOOD) performs morphological bottom-hat filtering where NHOOD is an array of 0's and 1's that specifies the size and shape of the structuring element. This is equivalent to imbothat(IM,strel(NHOOD)).

gpuarrayIM2 = imbothat(gpuarrayIM,___) performs operation on a graphics processing unit (GPU), where gpuarrayIM is a gpuArray of class uint8 or logical. This syntax requires the Parallel Computing Toolbox™.

Code Generation support: Yes.

MATLAB Function Block support: Yes.

Class Support

IM can be numeric or logical and must be nonsparse. If the input is binary (logical), then the structuring element must be flat.

gpuarrayIM must be a gpuArray of type uint8 or logical. When used with a gpuarray, the structuring element must be flat and two-dimensional.

The output has the same class as the input.


collapse all

Read image into the workspace and display it.

I = imread('pout.tif');

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));

Read the image into a gpuArray.

 original = gpuArray(imread('pout.tif'));

Create a disk-shaped structuring element, needed for morphological processing.

se = strel('disk',3);

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

contrastFiltered = ...

More About

collapse all

Code Generation

This function supports the generation of C code using MATLAB® Coder™. Note that if you choose the generic MATLAB Host Computer target platform, the function generates code that uses a precompiled, platform-specific shared library. Use of a shared library preserves performance optimizations but limits the target platforms for which code can be generated. For more information, see Understanding Code Generation with Image Processing Toolbox.

When generating code, the input image, IM, must be 2-D or 3-D and the structuring element argument SE must be a single element—arrays of structuring elements are not supported. To obtain the same result as that obtained using an array of structuring elements, call the function sequentially.

MATLAB Function Block

You can use this function in the MATLAB Function Block in Simulink.

Introduced before R2006a

Was this topic helpful?