Products & Services Solutions Academia Support User Community Company

Learn more about Image Processing Toolbox   

imtophat - Top-hat filtering

Syntax

IM2 = imtophat(IM,SE)
IM2 = imtophat(IM,NHOOD)

Description

IM2 = imtophat(IM,SE) performs morphological top-hat filtering on the grayscale or binary input image IM. Top-hat filtering computes the morphological opening of the image (using imopen) and then subtracts the result from the original image. imtophat uses the structuring element SE, where SE is returned by strel. SE must be a single structuring element object, not an array containing multiple structuring element objects.

IM2 = imtophat(IM,NHOOD) where NHOOD is an array of 0s and 1s that specifies the size and shape of the structuring element, is the same as imptophat(IM,strel(NHOOD)).

Class Support

IM can be numeric or logical and must be nonsparse. The output image IM2 has the same class as the input image. If the input is binary (logical), the structuring element must be flat.

Examples

You can use top-hat filtering to correct uneven illumination when the background is dark. This example uses top-hat filtering with a disk-shaped structuring element to remove the uneven background illumination from an image.

  1. Read an image into the MATLAB workspace.

    I = imread('rice.png');
    imshow(I)

  2. Create the structuring element and perform top-hat filtering of the image.

    se = strel('disk',12);
    J = imtophat(I,se);
    figure, imshow(J)

  3. Use imadjust to improve the visibility of the result.

    K = imadjust(J);
    figure, imshow(K)

See Also

imbothat, strel

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS