Hit-And-Miss operator from Mathematical Morphology.

Namespace:  AForge.Imaging.Filters
Assembly:  AForge.Imaging (in AForge.Imaging.dll) Version: 2.2.5.0 (2.2.5.0)

Syntax

C#
public class HitAndMiss : BaseUsingCopyPartialFilter

Remarks

The hit-and-miss filter represents generalization of Erosion and Dilatation filters by extending flexibility of structuring element and providing different modes of its work. Structuring element may contain:

  • 1 - foreground;
  • 0 - background;
  • -1 - don't care.

Filter's mode is set by Mode property. The list of modes and its documentation may be found in HitAndMiss..::.Modes enumeration.

The filter accepts 8 bpp grayscale images for processing. Note: grayscale images are treated as binary with 0 value equals to black and 255 value equals to white.

Sample usage:

CopyC#
// 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 );

Initial image:

Result image:

Inheritance Hierarchy

System..::.Object
  AForge.Imaging.Filters..::.BaseUsingCopyPartialFilter
    AForge.Imaging.Filters..::.HitAndMiss

See Also