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