Click or drag to resize
Accord.NET (logo)

BlobCounter Class

Blob counter - counts objects in image, which are separated by black background.
Inheritance Hierarchy
SystemObject
  Accord.ImagingBlobCounterBase
    Accord.ImagingBlobCounter

Namespace:  Accord.Imaging
Assembly:  Accord.Imaging (in Accord.Imaging.dll) Version: 3.8.0
Syntax
public class BlobCounter : BlobCounterBase
Request Example View Source

The BlobCounter type exposes the following members.

Constructors
  NameDescription
Public methodBlobCounter
Initializes a new instance of the BlobCounter class.
Public methodBlobCounter(Bitmap)
Initializes a new instance of the BlobCounter class.
Public methodBlobCounter(BitmapData)
Initializes a new instance of the BlobCounter class.
Public methodBlobCounter(UnmanagedImage)
Initializes a new instance of the BlobCounter class.
Top
Properties
  NameDescription
Public propertyBackgroundThreshold
Background threshold's value.
Public propertyBlobsFilter
Custom blobs' filter to use.
(Inherited from BlobCounterBase.)
Public propertyCoupledSizeFiltering
Specifies if size filtering should be coupled or not.
(Inherited from BlobCounterBase.)
Public propertyFilterBlobs
Specifies if blobs should be filtered.
(Inherited from BlobCounterBase.)
Protected propertyImageHeight
Gets the height of the image.
(Inherited from BlobCounterBase.)
Protected propertyImageWidth
Gets the width of the image.
(Inherited from BlobCounterBase.)
Public propertyMaxHeight
Maximum allowed height of blob.
(Inherited from BlobCounterBase.)
Public propertyMaxWidth
Maximum allowed width of blob.
(Inherited from BlobCounterBase.)
Public propertyMinHeight
Minimum allowed height of blob.
(Inherited from BlobCounterBase.)
Public propertyMinWidth
Minimum allowed width of blob.
(Inherited from BlobCounterBase.)
Public propertyObjectLabels
Objects' labels.
(Inherited from BlobCounterBase.)
Public propertyObjectsCount
Objects count.
(Inherited from BlobCounterBase.)
Public propertyObjectsOrder
Objects sort order.
(Inherited from BlobCounterBase.)
Top
Methods
  NameDescription
Protected methodBuildObjectsMap
Actual objects map building.
(Overrides BlobCounterBaseBuildObjectsMap(UnmanagedImage).)
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from BlobCounterBase.)
Protected methodDispose(Boolean)
Releases unmanaged and - optionally - managed resources.
(Inherited from BlobCounterBase.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodExtractBlobsImage(Bitmap, Blob, Boolean)
Extract blob's image.
(Inherited from BlobCounterBase.)
Public methodExtractBlobsImage(UnmanagedImage, Blob, Boolean)
Extract blob's image.
(Inherited from BlobCounterBase.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetBlobsEdgePoints
Get list of object's edge points.
(Inherited from BlobCounterBase.)
Public methodGetBlobsLeftAndRightEdges
Get list of points on the left and right edges of the blob.
(Inherited from BlobCounterBase.)
Public methodGetBlobsTopAndBottomEdges
Get list of points on the top and bottom edges of the blob.
(Inherited from BlobCounterBase.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetObjects(Bitmap, Boolean)
Get blobs.
(Inherited from BlobCounterBase.)
Public methodGetObjects(UnmanagedImage, Boolean)
Get blobs.
(Inherited from BlobCounterBase.)
Public methodCode exampleGetObjectsInformation
Get objects' information.
(Inherited from BlobCounterBase.)
Public methodGetObjectsRectangles
Get objects' rectangles.
(Inherited from BlobCounterBase.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodProcessImage(Bitmap)
Build objects map.
(Inherited from BlobCounterBase.)
Public methodProcessImage(BitmapData)
Build objects map.
(Inherited from BlobCounterBase.)
Public methodProcessImage(UnmanagedImage)
Build object map from raw image data.
(Inherited from BlobCounterBase.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

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

Note Note
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);

// process blobs
foreach (Rectangle rect in bc.GetObjectsRectangles())
{
    // ...
}
See Also