Documentation

imbothat

Bottom-hat filtering

Syntax

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

Description

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.

Examples

collapse all

Enhance Contrast Using Bottom-hat Filtering and Top-hat Filtering Together

Read the image and view it.

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

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.

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

Enhance Contrast using Bottom Hat Filtering on a GPU

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 = ...
       (original+imtophat(original,se))-imbothat(original,se);

More About

expand 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.

See Also

| |

Introduced before R2006a

Was this topic helpful?