Morphological structuring element
To create the following nonflat structuring element shapes,
The following syntaxes still work, but are not recommended for use.
strel object represents a flat morphological structuring
element, which is an essential part of morphological dilation
and erosion operations. (To create a nonflat structuring element,
A flat structuring element is a binary valued neighborhood,
either 2-D or multidimensional, in which the true pixels are included
in the morphological computation, and the false pixels are not. The
center pixel of the structuring element, called the origin,
identifies the pixel in the image being processed. Use the
strel function to create a flat
structuring element. You can use flat structuring elements with both
binary and grayscale images. The following figure illustrates a flat
SE = strel('diamond', creates
a diamond-shaped structuring element, where
the distance from the structuring element origin to the points of
SE = strel('disk', creates
a disk-shaped structuring element, where
N specifies the number of line structuring
elements used to approximate the disk shape. Morphological operations
using disk approximations run much faster when the structuring element
SE = strel('line', creates
a linear structuring element that is symmetric with respect to the
deg specifies the angle
(in degrees) of the line as measured in a counterclockwise direction
from the horizontal axis.
len is approximately
the distance between the centers of the structuring element members
at opposite ends of the line.
SE = strel('octagon', creates
a octagonal structuring element, where
the distance from the structuring element origin to the sides of the
octagon, as measured along the horizontal and vertical axes.
be a nonnegative multiple of 3.
SE = strel('rectangle', creates
a rectangular structuring element, where
SE = strel('cube', creates
a cubic structuring element whose width is
be a nonnegative integer scalar.
SE = strel('cuboid', creates
a cuboidal structuring element of size
SE = strel('arbitrary', creates
a structuring element, where
NHOOD is a matrix
of 1s and 0s that specifies the neighborhood. You can omit
Code Generation support: Yes.
MATLAB Function Block support: Yes.
R— Radius of the structuring element in the X-Y plane
Radius of the structuring element in the X-Y plane, specified as a nonnegative integer.
For the disk shape,
R is the distance from
the origin to the edge of the disk.
For the diamond shape,
R is the distance
from the structuring element origin to the points of the diamond.
N— Number of periodic line structuring elements used to approximate shape
Number of periodic line structuring elements used to approximate
shape, specified as the scalar value 0, 4, 6, or 8. When
greater than 0, the disk-shaped structuring element is approximated
by a sequence of
N periodic-line structuring
elements. When N is 0,
strel does no approximation,
and the structuring element members comprise all pixels whose centers
are no greater than
R away from the origin. Morphological
operations using disk approximations run much faster when the structuring
element uses approximations
(N > 0). Sometimes
it is necessary for
strel to use two extra line
structuring elements in the approximation, in which case the number
of decomposed structuring elements used is
N + 2.
|Value of N||Behavior|
MN— Size of rectangle-shaped structuring element
Size of rectangle-shaped structuring element, specified as a
two-element vector of nonnegative integers. The first element of
the number of rows in the structuring element neighborhood and the
second element is the number of columns.
W— Width of square-shaped or cube-shaped structuring element
Width of square-shaped or cube-shaped structuring element, specified as a nonnegative integer scalar.
XYZ— Dimensions of cuboidal-shaped structuring element
Dimensions of cuboidal-shaped structuring element, specified
as a three-element vector of nonnegative integers, of the form
X is the number of rows,
the number of columns, and
Z is the number of planes
in the third dimension.
Neighborhood, specified as a matrix containing 1's and 0's.
The location of the 1's defines the neighborhood for the morphological
operation. The center (or origin) of
its center element, given by
floor((size(nhood) + 1)/2).
Neighborhood— Structuring element neighborhood
Structuring element neighborhood, specified as a matrix of class
Dimensionality— Dimensions of structuring element
Dimensions of structuring element, specified as a nonnegative
scalar of class
Create an 11-by-11 square structuring element.
SE = strel('square', 11)
SE = strel is a square shaped structuring element with properties: Neighborhood: [11×11 logical] Dimensionality: 2
Create a line-shaped structuring element with a length of 10 at an angle of 45 degrees.
SE = strel('line', 10, 45)
SE = strel is a line shaped structuring element with properties: Neighborhood: [7×7 logical] Dimensionality: 2
View the structuring element.
ans = 7×7 logical array 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0
Create a disk-shaped structuring element with a radius of 15.
SE3 = strel('disk', 15)
SE3 = strel is a disk shaped structuring element with properties: Neighborhood: [29×29 logical] Dimensionality: 2
Display the disk-shaped structuring element.
Create a 3-D sphere-shaped structuring element with a radius of 15.
SE = strel('sphere', 15)
SE = strel is a sphere shaped structuring element with properties: Neighborhood: [31×31×31 logical] Dimensionality: 3
Display the structuring element.
Structuring elements that do not use approximations
= 0) are not suitable for computing granulometries.
This function supports the generation of C code using MATLAB® Coder™. For more information, see Code Generation for Image Processing.
When generating code, note the following:
All input arguments must be compile-time constants.
The methods associated with
are not supported in code generation.
strel objects are not
You can use this function in the MATLAB Function Block in Simulink.
For all shapes except
elements are constructed using a family of techniques known collectively
as structuring element decomposition. The principle
is that dilation by some large structuring elements can be computed
faster by dilation with a sequence of smaller structuring elements.
For example, dilation by an 11-by-11 square structuring element can
be accomplished by dilating first with a 1-by-11 structuring element
and then with an 11-by-1 structuring element. This results in a theoretical
performance improvement of a factor of 5.5, although in practice the
actual performance improvement is somewhat less. Structuring element
decompositions used for the
'disk' shape is an
approximations—all other decompositions are exact.
|decompose||Return sequence of decomposed structuring elements|
|reflect||Reflect structuring element|
|translate||Translate structuring element|
 van den Boomgard, R, and R. van Balen, "Methods for Fast Morphological Image Transforms Using Bitmapped Images," Computer Vision, Graphics, and Image Processing: Graphical Models and Image Processing, Vol. 54, Number 3, pp. 252–254, May 1992.
 Adams, R., "Radial Decomposition of Discs and Spheres," Computer Vision, Graphics, and Image Processing: Graphical Models and Image Processing, Vol. 55, Number 5, pp. 325–332, September 1993.
 Jones, R., and P. Soille, "Periodic lines: Definition, cascades, and application to granulometrie," Pattern Recognition Letters, Vol. 17, pp. 1057–1063, 1996.