Mathematical morphology filters
AForge.NET framework provides set of filters from mathematical morphology.
All of the filters may be applied as using default structuring element, as using
custom specified structuring element.
Below is the list of implemented mathematical morphology filters and the result of
their application to the below source image.
Source image
Erosion
The filter assigns minimum value of surrounding pixels to each pixel of the result image.

Dilatation
The filter assigns maximum value of surrounding pixels to each pixel of the result image.

Opening
Opening morphology operator equals to erosion followed by dilatation.

Closing
Closing morphology operator equals to dilatation followed by erosion.

Bottom Hat
Bottom-hat morphological operator subtracts input image from the result of morphological closing on the the input image.

Top Hat
Top-hat morphological operator subtracts result of morphological opening on the the input image from the input image itself.

Hit and Miss
The hit-and-miss filter represents generalization of Erosion and Dilatation filters by extending flexibility of structuring
elements and providing different modes of its work.
// define kernel to remove pixels on the right side of objects
// (pixel is removed, if there is white pixel on the left and
// black pixel on the right)
short[,] se = new short[,] {
{ -1, -1, -1 },
{ 1, 1, 0 },
{ -1, -1, -1 }
};
// create filter
HitAndMiss filter = new HitAndMiss( se, HitAndMiss.Modes.Thinning );
// apply the filter
filter.ApplyInPlace( image );
The framework also provides specialized versions of some morphological operators, which are optimized for certain cases. These
are: Erosion3x3 and
Dilatation3x3 for processing
of grayscale images with 3x3 structuring element and BinaryErosion3x3
and BinaryDilatation3x3 for
processing of binary images with 3x3 structuring element.
|