Main Content


Morphologically open image



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. The imopen function determines the center element of the neighborhood by floor((size(nhood)+1)/2).

This syntax is equivalent to imopen(I,strel(nhood)).


collapse all

Read the image into the workspace and display it.

original = imread('snowflakes.png');

Figure contains an axes. The axes contains an object of type image.

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 contains an axes. The axes contains an object of type image.

Input Arguments

collapse all

Input image, specified as a grayscale image or binary image of any dimension.

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]

Output Arguments

collapse all

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

Extended Capabilities

See Also



Introduced before R2006a