C# Class AForge.Imaging.RecursiveBlobCounter

Blob counter based on recursion.

The class counts and extracts stand alone objects in images using recursive version of 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.

Since this algorithm is based on recursion, it is required to be careful with its application to big images with big blobs, because in this case recursion will require big stack size and may lead to stack overflow. The recursive version may be applied (and may be even faster than BlobCounter) to an image with small blobs - "star sky" image (or small cells, for example, etc).

For blobs' searching the class supports 8 bpp indexed grayscale images and 24/32 bpp color images. 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 RecursiveBlobCounter bc = new RecursiveBlobCounter( ); // process binary image bc.ProcessImage( image ); Rectangle[] rects = bc.GetObjectsRectangles( ); // process blobs foreach ( Rectangle rect in rects ) { // ... }
Inheritance: BlobCounterBase
ファイルを表示 Open project: holisticware-admin/MonoVersal.AForgeNET

Public Methods

Method Description
RecursiveBlobCounter ( ) : System

Initializes a new instance of the RecursiveBlobCounter class.

Creates new instance of the RecursiveBlobCounter 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.

RecursiveBlobCounter ( Bitmap image ) : System

Initializes a new instance of the RecursiveBlobCounter class.

RecursiveBlobCounter ( BitmapData imageData ) : System

Initializes a new instance of the RecursiveBlobCounter class.

RecursiveBlobCounter ( UnmanagedImage image ) : System

Initializes a new instance of the RecursiveBlobCounter 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.

Private Methods

Method Description
LabelColorPixel ( byte pixel, int labelPointer ) : void
LabelPixel ( byte pixel, int labelPointer ) : void

Method Details

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.
protected BuildObjectsMap ( UnmanagedImage image ) : void
image UnmanagedImage Unmanaged image to process.
return void

RecursiveBlobCounter() public method

Initializes a new instance of the RecursiveBlobCounter class.
Creates new instance of the RecursiveBlobCounter 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 RecursiveBlobCounter ( ) : System
return System

RecursiveBlobCounter() public method

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

RecursiveBlobCounter() public method

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

RecursiveBlobCounter() public method

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