Documentation

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.

imopen

Morphologically open image

Syntax

J = imopen(I,SE)
J = imopen(I,nhood)
gpuarrayJ = imopen(gpuarrayI,___)

Description

example

J = imopen(I,SE) performs morphological opening on the grayscale or binary image I, returning the opened image, J. SE is a single structuring element object returned by the strel or offsetstrel functions. The morphological open operation is an erosion followed by a dilation, using the same structuring element for both operations.

J = imopen(I,nhood) opens the image I, where nhood is a matrix of 0s and 1s that specifies the structuring element neighborhood. This is equivalent to the syntax imopen(I,strel(nhood)). The imopen function determines the center element of the neighborhood by floor((size(nhood)+1)/2).

example

gpuarrayJ = imopen(gpuarrayI,___) opens an image, using a GPU. This syntax requires Parallel Computing Toolbox™.

Examples

collapse all

Read the image into the workspace and display it.

original = imread('snowflakes.png');
imshow(original);

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);
figure
imshow(afterOpening,[]);

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,[])

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.

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.

Structuring element neighborhood, specified as a matrix of 0s and 1s.

Example: [0 1 0; 1 1 1; 0 1 0]

Image to be opened on a GPU, specified as a gpuArray containing an image of type uint8 or logical. The structuring element SE must be flat and two-dimensional.

Output Arguments

collapse all

Opened image, returned as a grayscale image or binary image. J has the same class as input image I.

Opened image when run on a GPU, returned as a gpuArray. The output gpuarrayJ has the same class as the input gpuarrayI.

Extended Capabilities

See Also

Functions

Objects

Introduced before R2006a

Was this topic helpful?