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. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.


Morphologically open image


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


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

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

gpuarrayIM2 = imopen(gpuarrayIM,___) performs the operation on a graphics processing unit (GPU) with the structuring element strel(NHOOD), if NHOOD is an array of 0s and 1s that specifies the structuring element neighborhood, or strel(gather(NHOOD)) if NHOOD is a gpuArray object that specifies the structuring element neighborhood. This syntax requires the Parallel Computing Toolbox™.

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.


collapse all

Read the image into the workspace and display it.

original = imread('snowflakes.png');

Create a disk-shaped structuring element with a radius of 5 pixels.

se = strel('disk',5);

Remove snowflakes having a radius less than 5 pixels by opening it with the disk-shaped structuring element.

afterOpening = imopen(original,se);

Read an image.

 original = imread('snowflakes.png');

Create a disk-shaped structuring element.

se = strel('disk',5);

Morphologically open the image on a GPU, using a gpuArray object, and display the images.

afterOpening = imopen(gpuArray(original),se);
figure, imshow(original), figure, imshow(afterOpening,[])

Extended Capabilities

See Also


Using Objects

Introduced before R2006a

Was this topic helpful?