| MIL 10 Reference
| Customize Help
| Save Settings

MblobCalculate



See also
Availability
Not available in MIL-Lite
Available in MIL

Available on Windows
Available on Linux

Available on Non-Matrox computer
Available on Matrox 4Sight-X
Available on Matrox 4Sight GP
Available on Matrox Supersight
function map Function map
Examples
Synopsis
Perform blob analysis calculations.
Syntax
void MblobCalculate(
MIL_ID BlobIdentImageId, //in
MIL_ID GrayImageId, //in
MIL_ID FeatureListId, //in
MIL_ID BlobResId //in
)
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. Note that the blob identifier image and the grayscale image must be the same size.

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).

If you have associated the blob identifier image with a calibration context, and GrayImageId is set to M_NULL, the result buffer will be associated with the same calibration context as the blob identifier image. However, if you provide a grayscale image that is not calibrated or does not have the same calibration context as the blob identifier image, the result buffer will not be calibrated (both the identifier and grayscale images must have the same calibration context for the result to be calibrated).

You can limit blob analysis calculations to a region of the blob identifier image using a region of interest (ROI) set using MbufSetRegion(). In this case, the specified features in the feature list are only calculated for blobs (or parts of blobs) lying within the set ROI. Alternatively, you can define an ROI for the grayscale image. In this case, the ROI of the grayscale image is used as the blob identifier image and BlobIdentImageId must be set to M_NULL.

All calculations performed by this function are initially done in the pixel coordinate system. The result of these calculations can then be transformed into the appropriate coordinate system, and returned with respect to that system, if it is supported by the feature being calculated with M_RESULT_OUTPUT_UNITS. The MblobGetResult...() functions specify if the feature being calculated supports conversion to another coordinate system.

If you are calculating chain features (selected using MblobSelectFeature() or MblobSelect() with M_NUMBER_OF_CHAINED_PIXELS, M_CHAINS, M_CHAIN_X, M_CHAIN_Y, M_CHAIN_INDEX or M_ALL_FEATURES), you cannot use MblobControl() with M_BLOB_IDENTIFICATION set to M_LABELED_TOUCHING.

Note that this function reference has not been updated for a MIL system added during a MIL update. Refer to the MIL system's release note to see if there is complementary information.
Parameters
This function is not supported on the selected boards.
Parameters
BlobIdentImageId

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. The blob identifier image must be an unsigned, single band, packed binary, 8-bit or 16-bit grayscale image buffer.

This image buffer can have a region of interest defined using MbufSetRegion(). The region must be defined in raster format (M_RASTER or M_VECTOR_AND_RASTER). An error will be generated if the ROI is only in vector format (M_VECTOR).

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.

If this parameter is set to M_NULL, the ROI of the grayscale image is used as the blob identifier image. An error is generated if this parameter is set to M_NULL and there is either no grayscale image, or the grayscale image has no associated ROI.

Depending on the M_BLOB_IDENTIFICATION mode (set with MblobControl()), MblobCalculate() either treats each blob individually (M_INDIVIDUAL), groups all blobs together (M_WHOLE_IMAGE), groups blobs according to their actual pixel value in the blob identifier image (M_LABELED), or treats touching blobs that have different labels individually (M_LABELED_TOUCHING).

GrayImageId

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 grayscale image must be a single band, 8-bit or 16-bit unsigned grayscale image buffer.

This image buffer can have a region of interest defined using MbufSetRegion(). The region must be defined in raster format (M_RASTER or M_VECTOR_AND_RASTER). An error will be generated if the ROI is only in vector format (M_VECTOR).

FeatureListId

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

BlobResId

Specifies the identifier of a blob analysis result buffer, previously allocated with MblobAllocResult(), in which to store calculated results.

Compilation information
Header Include mil.h.
Library Use mil.lib; milblob.lib.
DLL Requires mil.dll; milblob.dll.
UNSIGNED PROC VECTOR UNSIGNED PROC VECTOR