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:
Filter's mode is set by Mode property. The list of modes and its documentation may be found in 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:
// 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: