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
the structuring element
SE. The argument
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
NHOOD is an array of 0's and 1's that specifies
the structuring element neighborhood.
gpuarrayIM2 = imopen(gpuarrayIM,___) performs
the operation on a graphics processing unit (GPU) with the structuring
an array of
1s that specifies
the structuring element neighborhood, or
gpuArray object that specifies the structuring
element neighborhood. This syntax requires the Parallel Computing Toolbox™.
Code Generation support: Yes.
MATLAB Function Block support: Yes.
IM can be any numeric or logical class and
any dimension, and must be nonsparse. If
SE must be flat.
gpuarrayIM must be a
used with a
gpuarray, the structuring element must
be flat and two-dimensional.
The output has the same class as the input.
Read the image into the MATLAB® workspace and display it.
original = imread('snowflakes.png'); figure, 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
and display the images.
afterOpening = imopen(gpuArray(original),se); figure, imshow(original), figure, imshow(afterOpening,)
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 image input argument,
must be 2-D or 3-D and the structuring element input argument,
must be a compile-time constant.
You can use this function in the MATLAB Function Block in Simulink.