The MIL Blob Analysis module can calculate a variety of different blob measurements or features, such as the area, perimeter, Feret diameter, and center of gravity of each selected blob. Although the MblobCalculate() function initiates the actual calculations, it is the specified feature list that determines which calculations will be performed.
When you first allocate the feature list with MblobAllocFeatureList(), no features are selected for calculation. You generally use the MblobSelectFeature() function to add features to this feature list. You can, however, use the more specialized MblobSelectMoment() or MblobSelectFeret() functions to select a specific moment or Feret diameter, respectively.
The Blob Analysis module supports both binary and grayscale features. When selecting a binary feature, all calculations are performed using only the blob identifier image. When grayscale features are selected for calculation, you must also provide the MblobCalculate() function with a grayscale image. The blob identifier image will identify the blobs, and the grayscale image will supply the actual blob pixel values.
When you call MblobCalculate(), the identifier image is scanned to locate blobs, and any selected features are calculated. Even if only a few features are selected, the overhead of scanning the image can be considerable. Therefore, it is usually more efficient to select many features and make one call to MblobCalculate(), rather than to select and calculate one feature at a time. Note, features that have already been calculated for the specified images will not be recalculated if you call MblobCalculate() again, unless any parameters of the calculation have changed.
There are several considerations when selecting features:
Before selecting a feature for calculation, you should take the blob shapes into consideration. Some features are more appropriate for certain blob shapes than for others. For example, some should be used for round blobs rather than long, thin ones, and vice versa.
When trying to distinguish between two similar blobs, selection of certain features, rather than some other features that might also seem appropriate, might reveal a more notable difference.
If two features allow you to come to the same conclusion, it is recommended that you select the one that is calculated more quickly. For example, features derived from multiple Feret diameters tend to calculate relatively slowly, and grayscale calculations are considerably longer than binary ones.
Note, for a visual representation of blobs that meet (or don't meet) certain criteria, call MblobFill() or MblobLabel() after calculating some features and calling MblobSelect(). These functions fill blobs with their own label values (MblobLabel()) or with a user-specified value (MblobFill()).
You can also use MblobDraw() to draw specific features of the results in an image buffer or a graphics list. For example, you can draw the blob's contours, holes, position, minimum and maximum Feret diameters, among other features. You can use a previously allocated graphics context (see the Graphics context section of Chapter 22: Generating graphics) to control the drawing color, or use the default graphics context (M_DEFAULT). You can draw into any supported MIL image buffer or a graphics list. By drawing into its display's overlay buffer, you can also annotate the image non-destructively. For more information, see the Annotating the displayed image non-destructively section of Chapter 21: Displaying an image.
To get results, you can use MblobGetResult() or MblobGetResultSingle(). MblobGetResult() retrieves results for all blobs, whereas MblobGetResultSingle() retrieves results for the specified blob. To specify a specific blob to MblobGetResultSingle(), use the blob's label obtained from MblobGetLabel() or MblobGetResult(). The Blob Analysis module automatically calculates label values for included blobs when a call to MblobCalculate() is made. You can obtain the label value for a specific blob using MblobGetLabel(), with the blob's coordinate. If you exclude some blobs from MblobCalculate(), the labels of the excluded blobs can still be returned until they are deleted; once deleted, the blob label returned will be 0.
The results obtained from MblobGetResult() can be sorted in ascending or descending order, by a maximum of three features assigned as sorting keys. To specify a feature as a sorting key, you can add M_SORTn_UP or M_SORTn_DOWN to the features selected with the following blob functions: MblobSelectFeature(), MblobSelectMoment(), MblobSelectFeret(). Replace n with 1, 2, or 3 to indicate the sorting precedence of the feature(s).