C# Class AForge.Imaging.BlobCounter

Blob counter - counts objects in image, which are separated by black background.

The class counts and extracts stand alone objects in images using connected components labeling algorithm.

The algorithm treats all pixels with values less or equal to BackgroundThreshold as background, but pixels with higher values are treated as objects' pixels.

For blobs' searching the class supports 8 bpp indexed grayscale images and 24/32 bpp color images that are at least two pixels wide. Images that are one pixel wide can be processed if they are rotated first, or they can be processed with RecursiveBlobCounter. See documentation about BlobCounterBase for information about which pixel formats are supported for extraction of blobs.

Sample usage:

// create an instance of blob counter algorithm BlobCounter bc = new BlobCounter( ); // process binary image bc.ProcessImage( image ); Rectangle[] rects = bc.GetObjectsRectangles( ); // process blobs foreach ( Rectangle rect in rects ) { // ... }
Inheritance: BlobCounterBase
Datei anzeigen Open project: holisticware-admin/MonoVersal.AForgeNET Class Usage Examples

Public Methods

Method Description
BlobCounter ( ) : System

Initializes a new instance of the BlobCounter class.

Creates new instance of the BlobCounter class with an empty objects map. Before using methods, which provide information about blobs or extract them, the BlobCounterBase.ProcessImage(Bitmap), BlobCounterBase.ProcessImage(BitmapData) or BlobCounterBase.ProcessImage(UnmanagedImage) method should be called to collect objects map.

BlobCounter ( Bitmap image ) : System

Initializes a new instance of the BlobCounter class.

BlobCounter ( BitmapData imageData ) : System

Initializes a new instance of the BlobCounter class.

BlobCounter ( UnmanagedImage image ) : System

Initializes a new instance of the BlobCounter class.

Protected Methods

Method Description
BuildObjectsMap ( UnmanagedImage image ) : void

Actual objects map building.

The method supports 8 bpp indexed grayscale images and 24/32 bpp color images.

Method Details

BlobCounter() public method

Initializes a new instance of the BlobCounter class.
Creates new instance of the BlobCounter class with an empty objects map. Before using methods, which provide information about blobs or extract them, the BlobCounterBase.ProcessImage(Bitmap), BlobCounterBase.ProcessImage(BitmapData) or BlobCounterBase.ProcessImage(UnmanagedImage) method should be called to collect objects map.
public BlobCounter ( ) : System
return System

BlobCounter() public method

Initializes a new instance of the BlobCounter class.
public BlobCounter ( Bitmap image ) : System
image System.Drawing.Bitmap Image to look for objects in.
return System

BlobCounter() public method

Initializes a new instance of the BlobCounter class.
public BlobCounter ( BitmapData imageData ) : System
imageData System.Drawing.Imaging.BitmapData Image data to look for objects in.
return System

BlobCounter() public method

Initializes a new instance of the BlobCounter class.
public BlobCounter ( UnmanagedImage image ) : System
image UnmanagedImage Unmanaged image to look for objects in.
return System

BuildObjectsMap() protected method

Actual objects map building.
The method supports 8 bpp indexed grayscale images and 24/32 bpp color images.
Unsupported pixel format of the source image. Cannot process images that are one pixel wide. Rotate the image /// or use .
protected BuildObjectsMap ( UnmanagedImage image ) : void
image UnmanagedImage Unmanaged image to process.
return void