An essential part of the morphological dilation and erosion operations is the structuring element used to probe the input image. A structuring element is a matrix that identifies the pixel in the image being processed and defines the neighborhood used in the processing of each pixel. You typically choose a structuring element the same size and shape as the objects you want to process in the input image. For example, to find lines in an image, create a linear structuring element.
There are two types of structuring elements: flat and
nonflat. 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 structuring element.
A nonflat structuring element is a matrix of type
identifies the pixel in the image being processed and defines the neighborhood used in
the processing of that pixel. A nonflat structuring element contains finite values used
as additive offsets in the morphological computation. The center pixel of the matrix,
called the origin, identifies the pixel in the image that is
being processed. Pixels in the neighborhood with the value
not used in the computation. Use the
offsetstrel function to create a nonflat structuring element. You can use
nonflat structuring elements only with grayscale images.
Determine the Origin of a Structuring Element
The morphological functions use this code to get the coordinates of the origin of structuring elements of any size and dimension:
origin = floor((size(nhood)+1)/2)
nhood is the neighborhood defining the structuring
element. To see the neighborhood of a flat structuring element, view the
Neighborhood property of the
To see the neighborhood of a nonflat structuring element, view the
Offset property of the
For example, the following illustrates the origin of a flat, diamond-shaped structuring element.
Structuring Element Decomposition
To enhance performance, the
offsetstrel functions might break
structuring elements into smaller pieces, a technique known as structuring
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 speed improvement of a factor of 5.5, although in practice the actual speed improvement is somewhat less.
Structuring element decompositions used for the
"ball" shapes are approximations; all other decompositions
are exact. Decomposition is not used with an arbitrary structuring element unless it
is a flat structuring element whose neighborhood matrix is all 1's.
To see the sequence of structuring elements used in a decomposition, use the
decompose method. Both
strel objects and
offsetstrel objects support decompose methods. The
decompose method returns an array of the structuring elements
that form the decomposition. For example, here are the structuring elements created
in the decomposition of a diamond-shaped structuring element.
SE = strel("diamond",4)
SE = strel is a diamond shaped structuring element with properties: Neighborhood: [9x9 logical] Dimensionality: 2
Call the decompose method. The method returns an array of structuring elements.
ans = 3x1 strel array with properties: Neighborhood Dimensionality