Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

imclose

Morphologically close image

Syntax

IM2 = imclose(IM,SE)
IM2 = imclose(IM,NHOOD)
gpuarrayIM2 = imclose(gpuarraryIM,___)

Description

IM2 = imclose(IM,SE) performs morphological closing on the grayscale or binary image IM, returning the closed image, IM2. The structuring element, SE, must be a single structuring element object, as opposed to an array of objects. The morphological close operation is a dilation followed by an erosion, using the same structuring element for both operations.

IM2 = imclose(IM,NHOOD) performs closing with the structuring element strel(NHOOD), where NHOOD is an array of 0's and 1's that specifies the structuring element neighborhood.

gpuarrayIM2 = imclose(gpuarraryIM,___) performs the operation on a graphics processing unit (GPU), where gpuarrayIM is a gpuArray containing the grayscale or binary image. gpuarrayIM2 is a gpuArray of the same class as the input image. This syntax requires the Parallel Computing Toolbox™.

Code Generation support: Yes.

MATLAB Function Block support: Yes.

Class Support

IM can be any numeric or logical class and any dimension, and must be nonsparse. If IM is logical, then SE 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

Read a binary image into the workspace and display it.

originalBW = imread('circles.png');
imshow(originalBW);

Create a disk-shaped structuring element. Use a disk structuring element to preserve the circular nature of the object. Specify a radius of 10 pixels so that the largest gap gets filled.

se = strel('disk',10);

Perform a morphological close operation on the image.

closeBW = imclose(originalBW,se);
figure, imshow(closeBW)

Use morphological closing to join the circles in an image together by filling in the gaps between them and by smoothing their outer edges.

Read the image into the MATLAB® workspace and view it.

originalBW = imread('circles.png');
imshow(originalBW);

Create a disk-shaped structuring element. Use a disk structuring element to preserve the circular nature of the object. Specify a radius of 10 pixels so that the largest gap gets filled.

se = strel('disk',10);

Perform a morphological close operation on the image on a GPU.

closeBW = imclose(gpuArray(originalBW),se);
figure, imshow(closeBW)

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?