Struct StructuringElement
- Namespace
- Egami.Operations
- Assembly
- Egami.dll
The shape Morphology(MorphologyOp, StructuringElement, int) takes its maximum or minimum over: a set of cells around an origin, which sits on the pixel being computed. The factories make the shapes ImageMagick's -morphology kernels of the same names make (its Plus is Cross(int) here). The default value is the origin alone, which changes nothing.
public readonly struct StructuringElement
- Inherited Members
Examples
StructuringElement disk = StructuringElement.Disk(4); // x² + y² ≤ 16, ImageMagick's Disk:4
StructuringElement diamond = StructuringElement.Diamond(3); // |x| + |y| ≤ 3
StructuringElement plus = StructuringElement.Cross(2); // ImageMagick's Plus:2
StructuringElement corner = StructuringElement.FromMask(
new[,]
{
{ true, true, true },
{ true, false, false },
{ true, false, false },
},
new Point(0, 0)); // [y, x] cells; the origin sits on the pixel
using Raster rounded = photo.Derive(o => o.Morphology(MorphologyOp.Open, disk, iterations: 2), Ct);
Properties
Height
Gets the height of the shape's bounding box in pixels.
public int Height { get; }
Property Value
Origin
Gets the origin's cell in the bounding box, from its top-left corner: the cell that sits on the pixel being computed.
public Point Origin { get; }
Property Value
Width
Gets the width of the shape's bounding box in pixels.
public int Width { get; }
Property Value
Methods
Cross(int)
A plus sign: the row and the column through the origin, each 2r + 1 long. ImageMagick calls it Plus:r.
public static StructuringElement Cross(int radius)
Parameters
radiusintThe length of each arm in pixels, from 0 to 1000.
Returns
- StructuringElement
The shape.
Exceptions
- ArgumentOutOfRangeException
radiusis negative or above 1000.
Diamond(int)
The cells with |x| + |y| ≤ r, a square standing on a corner: ImageMagick's Diamond:r.
public static StructuringElement Diamond(int radius)
Parameters
radiusintThe radius in pixels, from 0 to 1000.
Returns
- StructuringElement
The shape.
Exceptions
- ArgumentOutOfRangeException
radiusis negative or above 1000.
Disk(int)
The cells whose centers lie within radius of the origin's, x² + y² ≤ r²: ImageMagick's Disk:r.
public static StructuringElement Disk(int radius)
Parameters
radiusintThe radius in pixels, from 0 to 1000.
Returns
- StructuringElement
The shape.
Exceptions
- ArgumentOutOfRangeException
radiusis negative or above 1000.
FromMask(bool[,], Point)
Any shape: the set cells of cells, indexed [y, x], with origin on the pixel being computed.
public static StructuringElement FromMask(bool[,] cells, Point origin)
Parameters
cellsbool[,]The cells, [row, column]; at least one must be set, and each side at most 2001.
originPointThe origin's cell, (column, row); it need not be set.
Returns
- StructuringElement
The shape. It keeps its own copy of the cells.
Exceptions
- ArgumentNullException
cellsis null.- ArgumentException
No cell is set, or a side is 0 or above 2001.
- ArgumentOutOfRangeException
originlies outside the cells.
Rectangle(int, int)
A (2rx + 1) × (2ry + 1) rectangle centered on the origin: ImageMagick's Rectangle with those sizes, and Skia's dilate and erode radii.
public static StructuringElement Rectangle(int radiusX, int radiusY)
Parameters
radiusXintThe horizontal radius in pixels, from 0 to 1000.
radiusYintThe vertical radius in pixels, from 0 to 1000.
Returns
- StructuringElement
The shape.
Exceptions
- ArgumentOutOfRangeException
A radius is negative or above 1000.
Square(int)
A (2r + 1) square: ImageMagick's Square:r.
public static StructuringElement Square(int radius)
Parameters
radiusintThe radius in pixels, from 0 (the origin alone) to 1000.
Returns
- StructuringElement
The shape.
Exceptions
- ArgumentOutOfRangeException
radiusis negative or above 1000.