Hit-And-Miss operator from Mathematical Morphology.

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 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:

Inheritance: BaseUsingCopyPartialFilter
Ejemplo n.º 1
0
        public void HitAndMiss()
        {
            var se = new short[,] { { -1, -1, -1 },
                                    {  1,  1,  0 },
                                    { -1, -1, -1 } };

            HitAndMiss filter = new HitAndMiss(se, AForge.Imaging.Filters.HitAndMiss.Modes.Thinning);
            Grayscale grayScaler = new Grayscale(0.2125, 0.7154, 0.0721);
            _digit = filter.Apply(grayScaler.Apply(new Bitmap(_digit)));
        }