| MIL 10 User Guide
| Customize Help

Adjusting blob analysis processing controls



See also
Availability
Not available in MIL-Lite

Available in MIL

Before performing any blob analysis calculations, you should ensure the correct interpretation of the blob identifier image. Use MblobControl() to control how certain aspects of the blob identifier image are interpreted, for example:

  • Which pixel values are considered to be in the foreground (M_FOREGROUND_VALUE).

  • Whether two pixels touching at their corners are considered part of the same blob, by appropriately defining the image lattice (M_LATTICE).

  • Whether non-zero pixels can have any value or must be set to the maximum value of the buffer; for example, 0xff for an 8-bit buffer (M_IDENTIFIER_TYPE).

  • The pixel aspect ratio of the image (M_PIXEL_ASPECT_RATIO).

  • Whether to produce separate results for each blob or for groups of blobs (M_BLOB_IDENTIFICATION).

  • How many Feret angles are considered when calculating a Feret feature (M_NUMBER_OF_FERETS). Typically, the default value will be appropriate.

  • Whether partially computed results should be returned if the processing operation is interrupted (M_RETURN_PARTIAL_RESULTS).

Controlling the image lattice

MIL represents images using a square lattice and considers adjacent pixels along the vertical or horizontal axis as touching. However, you can control whether two diagonally adjacent pixels are considered touching.

Use MblobControl() to specify how the blob identifier image lattice should be interpreted. For example, the following is considered one blob if the lattice is set to M_8_CONNECTED, but two blobs if set to M_4_CONNECTED.

The pixel aspect ratio

When acquiring an image of a scene, each pixel represents some real distance both in width and in height. Ideally, this distance is the same in both directions, producing square pixels and allowing for simple feature calculations. However, after digitization, it is quite common for a pixel to represent a different distance in each direction. The ratio of the pixel's width to its height is called the pixel aspect ratio. For example, a pixel of equal width and height has a pixel aspect ratio of 1.0.

Note that if you have a calibrated image, feature results are returned in calibrated units.

In blob analysis, the pixel aspect ratio directly affects feature extractions. For example, all circular blobs are stretched or squashed if the pixels are not exactly square. In this case, you have two alternatives:

  • You can adjust your image, using MimResize(), and then make the required blob analysis feature extractions.

  • You can have calculations take the actual aspect ratio into consideration without modifying the image, by specifying the ratio, using MblobControl().

In both cases, the actual aspect ratio can be calculated using a simple procedure. Grab an image of a true circle or square and extract the M_FERET_X and M_FERET_Y features with the default pixel aspect ratio of 1.0. The relationship between these features represents the actual pixel aspect ratio to be used in calculations (M_FERET_Y / M_FERET_X).

Note, if your image has other types of distortions, you can use MimWarp() to adjust the image.

Note, all results are affected by the pixel aspect ratio, including those that are just positions within the image. For example, to mark M_BOX_X_MIN on an image with a graphics function, you must take the aspect ratio into account (in this case by dividing the returned result by the aspect ratio).

Setting the blob identification mode

Using MblobControl() with the blob identification mode setting (M_BLOB_IDENTIFICATION), you can control how blobs in the blob identifier image are grouped during calculations:

  • All blobs are measured individually (M_INDIVIDUAL).

  • All blobs are grouped together (M_WHOLE_IMAGE).

  • Different blobs with the same label, or touching blobs with different labels, are grouped together (M_LABELED).

  • Touching blobs with different labels are treated separately (M_LABELED_TOUCHING).

When using M_LABELED or M_LABELED_TOUCHING, M_FOREGROUND_VALUE cannot be set to M_ZERO, and the identifier image cannot be binary (1-bit). However, you can have the same behavior as M_LABELED or M_LABELED_TOUCHING with a binary (1-bit) identifier image, by setting M_BLOB_IDENTIFICATION to M_WHOLE_IMAGE and M_IDENTIFIER_TYPE to M_BINARY.

M_LABELED_TOUCHING is not supported with the following:

Calculations on blobs

When using the blob analysis package, you usually want to make feature calculations on each blob. For example, if you want to find the area of each cell in a tissue image, set the blob identification mode to M_INDIVIDUAL.

Sometimes, however, you need calculations based on the entire image rather than individual blobs. For example, you might want to calculate the area of all the copper in a rock sample image. MIL simplifies your task by allowing you to group all foreground pixels together by setting the blob identification mode to M_WHOLE_IMAGE. Blobs in an image are treated as one blob and features are calculated for this grouped blob.

Blob identification mode M_LABELED allows you to do joint calculations on blobs with the same label value, or touching blobs with different labels. When using labeled mode, ensure that each blob in the identifier image has a uniform pixel value. This value is the M_LABEL_VALUE result for that blob, and determines the grouping of the blobs. If the blobs that you would like to group do not have the same label, you can use MblobSelect() with M_MERGE to group blobs together and assign a common label to them.

To treat touching blobs as distinct, use the blob identification mode M_LABELED_TOUCHING. With this mode, you can perform calculations on individual blobs even though they're touching, provided each blob has a different label.

Returning partial results

Using MblobControl() with M_RETURN_PARTIAL_RESULTS, you can control whether partial results of the blob calculation will be available if the computation is interrupted by one of the following conditions:

  • The maximum number of blobs (M_MAX_BLOBS) has been processed.

  • The timeout limit (M_TIMEOUT) is exceeded.

Note that when partial results are requested and a timeout occurs, some results might not be available for certain blobs.