MblobSelectFeature()函数

Synopsis

Select feature(s) to be calculated.

Format

void MblobSelectFeature(FeatureListId, Feature)

MIL_ID FeatureListId; Feature list identifier
long Feature; Feature to be selected

Description

This function selects the feature(s) to be calculated by MblobCalculate when using the specified feature list.

The FeatureListId parameter specifies the identifier of the feature list buffer.

The Feature parameter specifies the feature to add to the feature list. To select several features, you must call this function for each feature you want to add to the list (certain commonly used groups of features can be selected in a single call).

Calculations can be performed on binary and grayscale images (see MblobCalculate). The following group of features do not use grayscale pixel values; they are calculated using only the blob identifier image. Note, the pixel aspect ratio (set with MblobControl) is taken into account horizontally for all feature calculations. Results that represent a position or length are expressed in units of “pixel height” (because this is independent of pixel aspect ratio). Also, note that you can change the number of Feret angles, for those features requiring them in calculations, using MblobControl.

Feature Description
M_LABEL_VALUE This is the label value for each blob in an image. This is a positive integer (>= 1) that is unique for each blob. This feature is always calculated; you do not need to select it.
M_AREA This is the number of foreground pixels in a blob (holes are not counted).
M_PERIMETER This is the total length of edges in a blob (including the edges of any holes), with an allowance made for the staircase effect that is produced when diagonal edges are digitized (inside corners are counted as 1.414, rather than 2.0). A single pixel blob (area = 1) has a perimeter of 4.0.
M_BOX_X_MIN, M_BOX_Y_MIN, M_BOX_X_MAX, M_BOX_Y_MAX These are the coordinates of the extreme left, top, right, and bottom pixels, respectively, of a blob.
M_FIRST_POINT_X, M_FIRST_POINT_Y Together, these define a unique point for each object, that is always on the perimeter of the object. The Y coordinate is that of the topmost line of the object, and the X coordinate is that of the leftmost pixel on that line.
M_FERET_X, M_FERET_Y These are the dimensions of the minimum bounding box of a blob in the horizontal and vertical directions (respectively); that is, M_BOX_X_MAX – M_BOX_X_MIN + 1, and similarly for the Y direction.
M_FERET_MIN_DIAMETER This is the smallest Feret diameter found after checking a certain number of angles. More angles will give a more accurate result, but will take longer to calculate. Even with the maximum number of angles (M_MAX_FERETS), this feature will not be very accurate for long thin blobs. However, you can get an accurate measure of the breadth of long thin blobs more quickly by using M_BREADTH.
M_FERET_MIN_ANGLE This is the angle at which the minimum Feret diameter is found. The value is in degrees, with positive values indicating a counter-clockwise displacement from the positive X-axis.
M_FERET_MAX_DIAMETER This is the largest Feret diameter found after checking a certain number of angles. More angles will give a more accurate result, but will take longer to calculate. However, the maximum Feret diameter is not very sensitive to the number of angles, and 8 usually gives an accurate result.
M_FERET_MAX_ANGLE This is the angle at which the maximum Feret diameter is found. The value is in degrees, with positive values indicating a counter-clockwise displacement from the positive X-axis.
M_FERET_MEAN_DIAMETER This is the average Feret diameter at all the angles checked.
M_FERET_ELONGATION This is a measure of the shape of a blob. It is equal to
M_FERET_MAX_DIAMETER / M_FERET_MIN_DIAMETER.
It is accurate for reasonably compact objects, but becomes less accurate for very elongated objects (because M_FERET_MIN_DIAMETER becomes less accurate). For very elongated objects, you should probably use M_ELONGATION.
M_CONVEX_PERIMETER This is an approximation of the perimeter of the convex hull of a blob. It is derived from several Feret diameters; so, a larger number of Ferets gives a more accurate result.
M_X_MIN_AT_Y_MIN, M_X_MAX_AT_Y_MAX, M_Y_MIN_AT_X_MAX , M_Y_MAX_AT_X_MIN These values, together with the four box coordinates, give four contact points on the convex perimeter of the object.
M_COMPACTNESS This value is a minimum for a circle (1.0) and is derived from the perimeter (p) and area (A). The more convoluted the shape, the greater the value. It is equal to:
BM2
M_NUMBER_OF_HOLES This value is equal to the number of holes in a blob. Holes that intersect the edge of the image are not counted (they may not be holes). This value is equal to
1 – M_EULER_NUMBER
and is therefore a true hole count only in M_INDIVIDUAL processing mode.
M_NUMBER_OF_RUNS This value is equal to the total number of runs in a blob. A run is defined as a horizontal string of consecutive foreground pixels.
M_ROUGHNESS This is a measure of how rough a blob is and is equal to
M_PERIMETER / M_CONVEX_PERIMETER.
A smooth convex object will have the minimum roughness of 1.0.
M_EULER_NUMBER This is: the number of blobs – number of holes. This value is more useful for M_WHOLE_IMAGE than for M_INDIVIDUAL processing mode.
M_LENGTH This is a measure of the true length of an object, although it can only be applied to certain object types because it is derived from the perimeter (P) and area (A) assuming that
P = 2(length + breadth) and
A = length*breadth.
It complements M_FERET_MAX_DIAMETER because it is accurate for different blob types (for example, long thin ones). Note, it is calculated much faster than the maximum Feret diameter.
M_BREADTH This is a measure of the true breadth of an object, with the same advantages and disadvantages as M_LENGTH.
M_ELONGATION This value is equal to
M_LENGTH / M_BREADTH.
It is similar to M_FERET_ELONGATION, except that it should be used for long thin objects.
M_INTERCEPT_0 This is the number of times a transition from background to foreground (not vice versa) occurs in the horizontal direction for the entire blob. In other words, it is equal to the number of times the neighborhood configuration
BM3
occurs in a blob, where B is a background pixel and F is a foreground pixel.
M_INTERCEPT_45 This is the number of times that the neighborhood configuration
BM4
occurs in a blob, where F is a foreground pixel, B is a background pixel and a dot can be any pixel value.
M_INTERCEPT_90 This is the number of times that the neighborhood configuration
BM5
occurs in a blob.
M_INTERCEPT_135 This is the number of times that the neighborhood configuration
BM6
occurs in a blob.
The following features require grayscale pixel values, and can only be calculated if you provide a grayscale image:
M_SUM_PIXEL This is the sum of all pixel values in a blob.
M_MIN_PIXEL This is the minimum pixel value found in a blob.
M_MAX_PIXEL This is the maximum pixel value found in a blob.
M_MEAN_PIXEL This is the mean pixel value in a blob. It is equal to
M_SUM_PIXEL / M_AREA.
M_SIGMA_PIXEL This is the standard deviation of pixel values in a blob. It is equal to:
BM7
where N = number of pixels and p = pixel value.
M_SUM_PIXEL_SQUARED This is the sum of the squares of each pixel value in a blob.

The following features have two different definitions: a binary definition, where all pixels are considered equal, and a grayscale, where pixels are weighted by their value in the gray image (the grayscale version is much slower to calculate).
If you don’t provide a grayscale image, only the binary version can be calculated. If you do provide a grayscale image, both versions are calculated. However, if you want a feature to be calculated in one version only, you can combine the selected feature with M_BINARY or M_GRAYSCALE (for example, M_CENTER_OF_GRAVITY_X + M_BINARY).

M_CENTER_OF_GRAVITY_X This is the X position of the center of gravity of a blob. The grayscale version is
M_MOMENT_X1_Y0 / M_SUM_PIXEL.
The binary version uses M_AREA instead of M_SUM_PIXEL.
M_CENTER_OF_GRAVITY_Y This is the Y position of the center of gravity of a blob. The grayscale version is
M_MOMENT_X0_Y1 / M_SUM_PIXEL.
The binary version uses M_AREA instead of M_SUM_PIXEL.
M_MOMENT_X0_Y1, M_MOMENT_X1_Y0, M_MOMENT_X1_Y1, M_MOMENT_X0_Y2, M_MOMENT_X2_Y0, M_MOMENT_CENTRAL_X0_Y2, M_MOMENT_CENTRAL_X2_Y0, M_MOMENT_CENTRAL_X1_Y1 Moments have the syntax M_MOMENT_Xn_Ym and are defined as:
BM8
where pi=value of a pixel (always 1 for binary moments), xi=its X coordinate and yi=its Y coordinate. For central moments, coordinates are relative to each blob’s center of gravity. Ordinary moments use coordinates relative to the image origin (top-left corner). Calculate higher moments by calling MblobSelectMoment.
M_AXIS_PRINCIPAL_ANGLE This is the angle at which a blob has the least moment of inertia (the axis of symmetry). For elongated blobs, it is aligned with the longest axis. The result is always between -90° and +90°, measured in a counter-clockwise direction from the positive X-axis. It is calculated as:
bm9
M_AXIS_SECONDARY_ANGLE This is the angle perpendicular to M_AXIS_PRINCIPAL_ANGLE. It is always between -90° and +90°.

The following predefined values allow you to select groups of features in a single call.

M_BOX Adds all 4 box features plus X and Y Ferets.
M_CONTACT_POINTS Adds first point and other contact features (M_X_MIN_AT_Y_MIN, M_X_MAX_AT_Y_MAX, M_Y_MIN_AT_X_MAX and M_Y_MAX_AT_X_MIN).
M_CENTER_OF_GRAVITY Adds both X and Y coordinates of the center of gravity.
M_ALL_FEATURES Adds all features (except general Feret and general moment).
M_NO_FEATURES Removes all features (except label value).

See also

MblobSelectMoment, MblobSelectFeret, MblobCalculate, MblobControl