Documentation Center

  • Trial Software
  • Product Updates

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

imbothat supports the generation of efficient, production-quality C/C++ code from MATLAB. When generating code, the image input argument, IM, must be 2-D or 3-D and the structuring element input argument, SE, must be a compile-time constant. Generated code for this function uses a precompiled platform-specific shared library. To see a complete list of toolbox functions that support code generation, see List of Supported Functions with Usage Notes.

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

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

See Also

| |

Was this topic helpful?