| MIL 10 User Guide
| Customize Help

Steps to performing blob analysis



See also
Availability
Not available in MIL-Lite

Available in MIL

The following steps provide a basic methodology for using the MIL Blob Analysis module:

  • Grab or load an image that was captured under the best possible conditions to minimize the amount of preprocessing required.

  • If necessary, reduce the amount of noise in the image. Noise makes the next step more difficult.

  • Segment the image so that blobs are separated from the background and from each other. Typically, this involves binarizing the image so that the background is in one state (zero or non-zero) and the blob pixels are in the other state. This image is known as the blob identifier image. If you plan to perform grayscale calculations, you will need the original grayscale image as well.

  • If necessary, preprocess the blob identifier image. If there are too many noise particles, calculation time will be increased. An opening operation (for non-zero blobs) or a closing operation (for zero blobs) will remove most of the noise particles without significantly affecting real blobs. You might also need to separate touching blobs at this stage (or they will be counted as a single blob).

  • Allocate a buffer for blob analysis results, using MblobAllocResult().

  • If necessary, adjust default blob analysis controls to fit your application, using MblobControl(). You can control the pixel aspect ratio, when to consider two pixels touching (along horizontal and vertical only or also along the diagonal), which values in the identifier image represent a blob (zero or non-zero), and whether or not non-zero pixels in the identifier image can have any value or must be set to the maximum value of the buffer (grayscale or binary). For example, the maximum value of an 8-bit buffer is 0xff.

  • Allocate a feature list, using MblobAllocFeatureList(). This list is used to specify the features that should be calculated. By default, this feature list is empty; no features are selected.

  • Calculate the required features and analyze the results. This involves the following:

    • Adding the required features into the feature list so that they will be calculated. Typically, you will use MblobSelectFeature() to perform this operation. However, when calculating moments or Feret diameters, you might need to use the more specialized feature selectors, MblobSelectMoment() or MblobSelectFeret(), respectively.

    • Specifying certain features as sorting keys. MblobSelectFeature(), MblobSelectMoment(), and MblobSelectFeret() each allow you to specify a selected feature as a sorting key. The calculated results are sorted in accordance with the sorting key selection.

    • Calculating results for the selected features, using MblobCalculate(). For this function, you will have to specify the blob identifier image that will be used to identify the blobs and calculate binary features, and (optionally) the grayscale image that will be used to calculate grayscale features.

    • If necessary, excluding or deleting blobs that do not meet the criteria, using MblobSelect(). Results for the excluded or deleted blobs will not be returned. Excluded blobs will be ignored in future calculations, while deleted blobs will be removed from the blob analysis result buffer altogether.

    • Getting the number of blobs currently included, using MblobGetNumber(), and retrieving the results from the blob result buffer, using MblobGetResult(). You can also use MblobGetResultSingle() to obtain results for a single blob and use MblobGetLabel() and MblobGetRuns() to obtain more specific results. Note that trying to retrieve a result which is not available generates an error.

You can repeat this step until you obtain all required results for the blobs of interest. Note, the process of excluding or deleting unwanted blobs and then calculating more features is the preferred method if you have many unwanted blobs. If this is not the case, it is often faster to calculate all the required features for all the blobs with a single call to MblobCalculate(), and then exclude or delete unwanted blob results afterwards.