Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

strel

Morphological structuring element

Description

A strel object represents a flat morphological structuring element, which is an essential part of morphological dilation and erosion operations.

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 (described below) 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.

To create a nonflat structuring element, use offsetstrel.

Creation

Syntax

SE = strel('diamond',r)
SE = strel('disk',r,n)
SE = strel('line',len,deg)
SE = strel('octagon',r)
SE = strel('rectangle',mn)
SE = strel('square',w)
SE = strel('cube',w)
SE = strel('cuboid',xyz)
SE = strel('sphere',r)
SE = strel('arbitrary',nhood)

Description

SE = strel('diamond',r) creates a diamond-shaped structuring element, where r specifies the distance from the structuring element origin to the points of the diamond.

example

SE = strel('disk',r,n) creates a disk-shaped structuring element, where r specifies the radius. 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 uses approximations.

example

SE = strel('line',len,deg) creates a linear structuring element that is symmetric with respect to the neighborhood center. 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',r) creates a octagonal structuring element, where r specifies the distance from the structuring element origin to the sides of the octagon, as measured along the horizontal and vertical axes. r must be a nonnegative multiple of 3.

SE = strel('rectangle',mn) creates a rectangular structuring element, where mn specifies the size.

example

SE = strel('square',w) creates a square structuring element whose width is w pixels.

SE = strel('cube',w) creates a cubic structuring element whose width is w pixels. w must be a nonnegative integer scalar.

SE = strel('cuboid',xyz) creates a cuboidal structuring element of size xyz.

example

SE = strel('sphere',r) creates a spherical structuring element whose radius is r pixels.

SE = strel('arbitrary',nhood) creates a structuring element, where nhood is a matrix of 1s and 0s that specifies the neighborhood. You can omit 'arbitrary' and specify strel(nhood).

Compatibility

The following syntaxes still work, but offsetstrel is the preferred way to create these nonflat structuring element shapes:

  • SE = strel('arbitrary',nhood,h)

  • SE = strel('ball',r,h,n)

The following syntaxes still work, but are not recommended for use:

  • SE = strel('pair',OFFSET)

  • SE = strel('periodicline',p,v)

Input Arguments

expand all

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.

Data Types: double

Number of periodic line structuring elements used to approximate shape, specified as the scalar value 0, 4, 6, or 8. When n is 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 nBehavior
n > 0strel uses a sequence of n (or sometimes n+2) periodic line-shaped structuring elements to approximate the shape.
n = 0strel does not use any approximation. The structuring element members comprise all pixels whose centers are no greater than r away from the origin and the corresponding height values are determined from the formula of the ellipsoid specified by r and h.

Data Types: double

Size of rectangle-shaped structuring element, specified as a two-element vector of nonnegative integers. The first element of mn is the number of rows in the structuring element neighborhood, and the second element is the number of columns.

Data Types: double

Width of square-shaped or cube-shaped structuring element, specified as a nonnegative integer scalar.

Data Types: double

Dimensions of cuboidal-shaped structuring element, specified as a three-element vector of nonnegative integers, of the form [x y x]. x is the number of rows, y is the number of columns, and z is the number of planes in the third dimension.

Data Types: double

Neighborhood, specified as a matrix containing 1s and 0s. The location of the 1s defines the neighborhood for the morphological operation. The center (or origin) of nhood is its center element, given by floor((size(nhood) + 1)/2).

Data Types: double

Properties

expand all

Structuring element neighborhood, specified as a logical matrix.

Data Types: logical

Dimensions of structuring element, specified as a nonnegative scalar.

Data Types: double

Object Functions

decomposeReturn sequence of decomposed structuring elements
reflectReflect structuring element
translateTranslate structuring element

Examples

expand all

Create an 11-by-11 square structuring element.

SE = strel('square', 11)
SE = 
strel is a square shaped structuring element with properties:

      Neighborhood: [11x11 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: [7x7 logical]
    Dimensionality: 2

View the structuring element.

SE.Neighborhood
ans = 7x7 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: [29x29 logical]
    Dimensionality: 2

Display the disk-shaped structuring element.

figure
imshow(SE3.Neighborhood)

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: [31x31x31 logical]
    Dimensionality: 3

Display the structuring element.

figure
isosurface(SE.Neighborhood)

Tips

  • Structuring elements that do not use approximations (n = 0) are not suitable for computing granulometries.

Algorithms

For all shapes except 'arbitrary', structuring 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.

References

[1] 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.

[2] 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.

[3] Jones, R., and P. Soille, "Periodic lines: Definition, cascades, and application to granulometrie," Pattern Recognition Letters, Vol. 17, pp. 1057–1063, 1996.

Extended Capabilities

Introduced before R2006a

Was this topic helpful?