StructuringElement Class

An immutable structuring element: the neighborhood of a pixel that the morphological filters read (ImageProcessingExtensions.Erode, ImageProcessingExtensions.Dilate and the operations made of them). It is flat: every pixel of the neighborhood counts the same.

public sealed class StructuringElement

Remarks

The neighborhood is centered on the pixel and symmetric: it holds the offset (dx, dy) when it holds (-dx, -dy). A rectangle (StructuringElement.CreateRectangle) is filtered in two passes, a row then a column, in a time per pixel that does not depend on its size; an ellipse (StructuringElement.CreateEllipse), which rounds the corners, takes a time per pixel that grows with its height: every row is filtered once per distinct width of the rows of the ellipse, then each output sample compares one filtered sample per row of the ellipse.

Properties

NameDescription
HeightGets the number of pixels of a column of the bounding box, 2 RadiusY + 1.
RadiusXGets the number of pixels on each side of the center, horizontally.
RadiusYGets the number of pixels on each side of the center, vertically.
WidthGets the number of pixels of a row of the bounding box, 2 RadiusX + 1.

Gets the number of pixels of a column of the bounding box, 2 RadiusY + 1.

public int Height { get; }

Property value

int

Gets the number of pixels on each side of the center, horizontally.

public int RadiusX { get; }

Property value

int

Gets the number of pixels on each side of the center, vertically.

public int RadiusY { get; }

Property value

int

Gets the number of pixels of a row of the bounding box, 2 RadiusX + 1.

public int Width { get; }

Property value

int

Methods

NameDescription
Contains(int, int)Gets a value indicating whether the element holds an offset from its center.
CreateEllipse(int, int)Creates an ellipse: the offsets (dx, dy) such that (dx / radiusX)^2 + (dy / radiusY)^2 <= 1, computed exactly in integers. With equal radii, it is the disk of scikit-image's morphology.disk(radius). A radius of 0 gives a line along the other axis.
CreateRectangle(int, int)Creates a rectangle of 2 radiusX + 1 by 2 radiusY + 1 pixels: the neighborhood of ImageProcessingExtensions.MedianBlur when both radii are equal, and the rectangle of OpenCV's MORPH_RECT and of SciPy's size parameter.

Contains(int, int)

StructuringElement.cs

Gets a value indicating whether the element holds an offset from its center.

public bool Contains(int dx, int dy)

Parameters

dx int
The horizontal offset, positive to the right.
dy int
The vertical offset, positive downward.

Returns

bool true when the pixel at this offset is part of the neighborhood.

CreateEllipse(int, int)

StructuringElement.cs

Creates an ellipse: the offsets (dx, dy) such that (dx / radiusX)^2 + (dy / radiusY)^2 <= 1, computed exactly in integers. With equal radii, it is the disk of scikit-image's morphology.disk(radius). A radius of 0 gives a line along the other axis.

public static StructuringElement CreateEllipse(int radiusX, int radiusY)

Parameters

radiusX int
The number of pixels on each side of the center, horizontally, from 0 to 1000.
radiusY int
The number of pixels on each side of the center, vertically, from 0 to 1000.

Returns

StructuringElement The structuring element.

Exceptions

ArgumentOutOfRangeException
A radius is negative or exceeds 1000.

CreateRectangle(int, int)

StructuringElement.cs

Creates a rectangle of 2 radiusX + 1 by 2 radiusY + 1 pixels: the neighborhood of ImageProcessingExtensions.MedianBlur when both radii are equal, and the rectangle of OpenCV's MORPH_RECT and of SciPy's size parameter.

public static StructuringElement CreateRectangle(int radiusX, int radiusY)

Parameters

radiusX int
The number of pixels on each side of the center, horizontally, from 0 to 1000.
radiusY int
The number of pixels on each side of the center, vertically, from 0 to 1000.

Returns

StructuringElement The structuring element.

Exceptions

ArgumentOutOfRangeException
A radius is negative or exceeds 1000.