This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

imbothat

Bottom-hat filtering

Syntax

J = imbothat(I,SE)
J = imbothat(I,nhood)

Description

example

J = imbothat(I,SE) performs morphological bottom-hat filtering on the grayscale or binary image I, returning the filtered image, J. Bottom-hat filtering computes the morphological closing of the image (using imclose) and then subtracts the original image from the result. SE is a single structuring element object returned by the strel or offsetstrel functions.

You optionally can perform the bottom-hat filtering using a GPU (requires Parallel Computing Toolbox™). For more information, see Image Processing on a GPU.

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 is equivalent to the syntax imbothat(I,strel(nhood)). The imbothat function determines the center element of the neighborhood by floor((size(nhood)+1)/2).

Examples

collapse all

Read image into the workspace and display it.

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

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)

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

Input Arguments

collapse all

Input image, specified as a grayscale image or binary image. I can have any dimension, and must be real and nonsparse.

To perform the bottom-hat filtering using a GPU, specify I as a gpuArray that contains an image of type uint8 or logical.

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.

If you perform the bottom-hat filtering using a GPU, then SE must be flat and two-dimensional.

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 class as input image I.

If the filtering is performed using a GPU, then J is returned as a gpuArray that contains a grayscale or binary image of the same class as I.

Extended Capabilities

See Also

Functions

Objects

Introduced before R2006a