MblobCalculate()函数

Synopsis

Perform blob analysis calculations.

Format

void MblobCalculate(BlobIdentImageId, GrayImageId, FeatureListId, BlobResId)

MIL_ID BlobIdentImageId; Blob identifier image identifier
MIL_ID GrayImageId; Optional grayscale image identifier
MIL_ID FeatureListId; Feature list identifier
MIL_ID BlobResId; Blob analysis result buffer identifier

Description

This function calculates the features specified in the given feature list for all currently included blobs in the blob identifier image and stores results in the specified result buffer. Features are added to the feature list with MblobSelectFeature, MblobSelectFeret, and MblobSelectMoment. Specific blobs can be selected using MblobSelect.

Calculations on binary features (such as M_AREA) are performed using only the BlobIdentImageId parameter. If a grayscale feature (such as M_MAX_PIXEL) is to be calculated, an image buffer must be specified for the GrayImageId parameter. In this case, the blob identifier image will be used to identify the blobs and the pixel values in the grayscale image are used to calculate the features.

If several calls are made to MblobCalculate with the same image and result buffer, features calculated in one call remain in the result buffer and are not recalculated in subsequent calls. However, if you then use a result buffer with different images or if you change its processing mode with MblobControl, any results already in the buffer become invalid and will be discarded. Therefore, it is more efficient to use a result buffer exclusively in one processing mode with one blob identifier image (or one identifier/grayscale image pair if grayscale features are needed).

The BlobIdentImageId parameter specifies the blob identifier image that will be used in calculations. The blob identifier image identifies each blob as a group of touching pixels in the current foreground state (zero or non-zero, depending on the value assigned to M_FOREGROUND_VALUE processing mode in MblobControl). The current M_LATTICE processing mode (also set with MblobControl), determines when to consider pixels as touching.

If the identifier image has previously been binarized so that it contains only two extreme values (0 and 1 for 1-bit images, 0 and 0xff for 8-bit images, and 0 and 0xffff for 16-bit images), blob analysis can be performed a little faster. However, you must first change the M_IDENTIFIER_TYPE to M_BINARY, using MblobControl, to let MIL know that the identifier image has only two states.

Depending on the M_BLOB_IDENTIFY mode (set with MblobControl), MblobCalculate either treats each blob individually (M_INDIVIDUAL), groups all blobs together (M_WHOLE_IMAGE), or groups blobs according to their actual pixel value in the blob identifier image (M_LABELLED).

The GrayImageId parameter specifies the grayscale image (not a binary buffer) that will be used to calculate grayscale features. If this parameter is set to M_NULL, grayscale features, such as M_SUM_PIXEL, cannot be calculated. This parameter is ignored when calculating only binary type features.

The FeatureListId parameter specifies the identifier of the feature list buffer, previously allocated with MblobAllocFeatureList, that specifies the feature(s) to calculate.

The BlobResId parameter specifies the identifier of a blob analysis result buffer, previously allocated with MblobAllocResult, in which to store calculated results.

Note

This function is optimized for packed binary buffers.

See also

MblobControl, MblobAllocFeatureList, MblobAllocResult, MblobSelectFeature, MblobSelectFeret, MblobSelectMoment, MblobSelect, MblobGetNumber, MblobGetResult, MblobGetResultSingle, MblobGetLabel, MblobGetRuns