Core Optical, Inc.
MorphologicalProcessor GetErodedBinaryMask Method Industrial Strength, Scientific Grade
Returns an eroded version of the input BinaryMask image.

Namespace: PrecisionImage.BinarizationAndMorphology
Assembly: PrecisionImage (in PrecisionImage.dll) Version: (

public BinaryMask GetErodedBinaryMask(
	BinaryMask binaryMask,
	BinaryMask structuringElement

Return Value

A BinaryMask object containing the results of the morphological erosion operation.

OnlineSystem ArgumentNullException Thrown when binaryMask and/or structuringElement is null.
OnlineSystem ArgumentException Thrown when the dimensions of structuringElement exceeds those of binaryMask.
OnlineSystem ArgumentException Thrown when either dimension of structuringElement is an even value.

Use this method to apply a binary erosion operation to the input BinaryMask. The erosion is performed using the specified structuring element, itself another BinaryMask. The most common type of structuring element is a circular erosion mask which can be retrieved via the static GetCircularStructuringElement(Int32) utility method. The result of the erosion operation is returned as another BinaryMask object.


The following example iteratively applies an erosion operation to a binary mask object (generated from thresholded data contained in "sourceData"):
using PrecisionImage;
using PrecisionImage.BinarizationAndMorphology;

// Apply optimum global threshold: 
OtsuThresholder thresholder = new OtsuThresholder();
BinaryMask objectMask = thresholder.GetThresholdBinaryMask(sourceData, 0, HistogramResolution.EightBit);

// Erode the binary object using a circular stucturing element with a radius of 2:
MorphologyProcessor morphProcessor = new MorphologyProcessor();
for(Int32 x = 0; x<NumIterations; x++)
    objectMask = morphProcessor.GetErodedBinaryMask(objectMask, BinaryMask.GetCircularStructuringElement(2));
See Also