| Customize Help

Edge features



Edge Finder allows you to calculate many edge features that can provide useful information, such as the edge's length and center of gravity. To enable (M_ENABLE) or disable (M_DISABLE) the calculation of a specific edge feature, use MedgeControl(); you can also select a group of features for calculation in a single call. To know the calculation state of a feature, use MedgeInquire(). To retrieve the results of the feature calculation, use MedgeGetResult(). For more information on retrieving results, see the Retrieving the results subsection of the Calculating and retrieving results section later in this chapter.

Note that the label feature (M_LABEL_VALUE) is the only edge feature that is enabled by default. The label value is a positive integer greater or equal to one; it is assigned to each edge in an image for identification. Each edge in an image has a unique label value. The label allows you to track or choose particular edges for drawing, edge manipulation, or result retrieval purposes. Typically, you should not disable the edge's label value.

Edge features generally fall into one of the following groups:

  • Dimension features (typically very fast to compute).

  • Location features (typically fast to compute).

  • Advanced features (can take some time to compute, due to their complexity).

To compute features as efficiently as possible, you should calculate a few features first (preferably, the fastest), and eliminate as many unnecessary edges as possible. Then, post-calculate expensive features on the remaining edges. For more information on how to select and post-calculate edges, see the Calculating and retrieving results section later in this chapter.

Note that, occasionally, enabling a feature for calculation will result in another feature being calculated and available for result retrieval. For example, enabling M_MOMENT_ELONGATION for calculation in MedgeControl() will allow you to retrieve the result of M_CENTER_OF_GRAVITY in MedgeGetResult(), even if you have disabled the calculation of the center of gravity.

The following subsections list all the Edge Finder features that you can enable or disable for calculation using MedgeControl(), according to dimension, location, and advanced application. There is also a subsection on selecting a group of features for calculation in a single call. Note that only the more complicated features are explained in some detail. For a description of each feature, see MedgeControl() in the MIL Reference.

Dimension features

The Edge Finder dimension features are:

M_CLOSURE

M_ELLIPSE_FIT_MAJOR_AXIS

M_FERET_X

M_CIRCLE_FIT_CENTER_X

M_ELLIPSE_FIT_MINOR_AXIS

M_FERET_Y

M_CIRCLE_FIT_CENTER_Y

M_FAST_LENGTH

M_FERET_GENERAL

M_CIRCLE_FIT_COVERAGE

M_FERET_BOX

M_FERET_GENERAL_ANGLE

M_CIRCLE_FIT_ERROR

M_FERET_ELONGATION

M_LENGTH

M_CIRCLE_FIT_RADIUS

M_FERET_MAX_ANGLE

M_LINE_FIT_A

M_ELLIPSE_FIT_ANGLE

M_FERET_MAX_DIAMETER

M_LINE_FIT_B

M_ELLIPSE_FIT_CENTER_X

M_FERET_MEAN_DIAMETER

M_LINE_FIT_C

M_ELLIPSE_FIT_CENTER_Y

M_FERET_MIN_ANGLE

M_LINE_FIT_ERROR

M_ELLIPSE_FIT_COVERAGE

M_FERET_MIN_DIAMETER

M_SIZE

M_ELLIPSE_FIT_ERROR

Feret diameter

A Feret diameter of an edge is its diameter at a specific angle. Several Feret diameters are illustrated in the diagram below. Note that the angle at which the Feret diameter is taken (relative to the horizontal axis) is specified as a subscript to F.

Some features, such as the edge's maximum Feret diameter, are determined by testing the Feret diameter of the edge at several angles. You can specify the angular range to use to calculate the Feret features, using MedgeControl() with M_FERET_ANGLE_SEARCH_END and M_FERET_ANGLE_SEARCH_START. The search is done in the counter-clockwise direction. To set the number of angles to test within the specified angular range, use MedgeControl() with M_NUMBER_OF_FERETS. The difference between successive angles is (M_FERET_ANGLE_SEARCH_END - M_FERET_ANGLE_SEARCH_START) / M_NUMBER_OF_FERETS . The default number of angles tested is 8, which is typically sufficient. Note that increasing the number of Feret angles increases the accuracy of the results; however, it also increases the processing time.

Circle fit and line fit

The circle fit is calculated as the circle that best fits the edge, while the line fit is calculated as the line that best fits the edge.

To calculate the coordinates of the center of the circle that is the best fit for each edge, use M_CIRCLE_FIT_CENTER_X and M_CIRCLE_FIT_CENTER_Y. To calculate the radius of the circle that is the best fit for each edge, use M_CIRCLE_FIT_RADIUS.

To calculate the coefficients A, B, and C that define the line that is the best fit for each edge, use M_LINE_FIT_A, M_LINE_FIT_B, and M_LINE_FIT_C. Note that these coefficients are based on the linear equation, A x + B y + C = 0.

To calculate the coverage of the circle fit, use M_CIRCLE_FIT_COVERAGE. The coverage indicates what angular fraction of the fitted circle is subtended by the radii going to the endpoints of the edge. The value returned is between 0.0 and 1.0, inclusive. For example, if the edge is closed, the coverage is 1.0 (100% coverage), for a quarter circle the coverage is 0.25 (25% coverage).

Note that since a line is theoretically infinite, it is impractical to calculate its coverage.

You can also calculate the error of either the circle fit or line fit using M_CIRCLE_FIT_ERROR or M_LINE_FIT_ERROR, respectively. These values are calculated as the average quadratic error of the fit.

Ellipse fit

The ellipse fit is calculated as the ellipse that best fits the edge.

To calculate the coordinates of the center of the ellipse that is the best fit for each edge, use M_ELLIPSE_FIT_CENTER_X and M_ELLIPSE_FIT_CENTER_Y. To calculate the major and minor axes of the ellipse that is the best fit for each edge, use M_ELLIPSE_FIT_MAJOR_AXIS and M_ELLIPSE_FIT_MINOR_AXIS, respectively.

To calculate the angle of the ellipse fit, use M_ELLIPSE_FIT_ANGLE. To calculate the error of the ellipse fit, use M_ELLIPSE_FIT_ERROR. This value is calculated as the average quadratic error of the fit.

Location features

The Edge Finder location features are:

M_BOX

M_CENTER_OF_GRAVITY_X

M_POSITION_X

M_BOX_X_MAX

M_CENTER_OF_GRAVITY_Y

M_POSITION_Y

M_BOX_X_MIN

M_CONTACT_POINTS

M_X_MAX_AT_Y_MAX

M_BOX_Y_MAX

M_FIRST_POINT

M_Y_MAX_AT_X_MIN

M_BOX_Y_MIN

M_FIRST_POINT_X

M_X_MIN_AT_Y_MIN

M_CENTER_OF_GRAVITY

M_FIRST_POINT_Y

M_Y_MIN_AT_X_MAX

The following edge map illustrates where each edge location feature is located:

Advanced features

The Edge Finder advanced features are:

M_AVERAGE_STRENGTH

M_MOMENT_ELONGATION

M_STRENGTH

M_CONVEX_PERIMETER

M_MOMENT_ELONGATION_ANGLE

M_TORTUOSITY

Convex perimeter

If you enable the convex perimeter feature (M_CONVEX_PERIMETER), an approximation of the perimeter of each edge's convex hull will be calculated. Abstractly, an edge's convex perimeter is very much like taking a rubber band, and placing it tautly around the edge.

The convex perimeter is derived by taking the diameter of the edge at different angles. The greater the number of Ferets used to calculate the diameter, the more accurate the approximation. Use MedgeControl() with M_NUMBER_OF_FERETS to adjust the number of Ferets. Note that increasing the number of Ferets increases the accuracy of the results; however, it also increases the processing time.

Tortuosity

An edge's tortuosity (M_TORTUOSITY) is the diagonal length of the edge's bounding box (M_BOX), divided by the length of the edge (M_LENGTH). Therefore, a non-tortuous edge (a straight line) will have a tortuosity of 1, while a tortuous edge (a curvy line) will have its tortuosity decreasing towards 0. A tortuosity that is close to 1 is considered low while a tortuosity that is close to 0 is considered high.

Moment elongation

The moment elongation (M_MOMENT_ELONGATION) is a geometric elongation measure of the edge. It is defined as the ratio of the principal values of the edge's inertial matrix, which corresponds to the principal directions of the edge shape. This can be approximately defined as the ratio between the edge's minimum and maximum moment. The elongation value varies from 0.0 to 1.0. Values closer to 1.0 are considered to have a low elongation, while values closer to 0.0 are considered to have a high elongation.

Note that you can also calculate the angle of the principal axis along each edge's moment elongation, using M_MOMENT_ELONGATION_ANGLE.

Grouped features

The Edge Finder features that allow you to select a group of features for calculation in a single call are:

M_ALL_FEATURES

M_ELLIPSE_FIT

M_BOX

M_FERET_BOX

M_CENTER_OF_GRAVITY

M_FIRST_POINT

M_CIRCLE_FIT

M_LINE_FIT

M_CONTACT_POINTS

M_POSITION

Each of these features has multiple features associated with it. Therefore, if you enable one of them for calculation, then all the features associated with it will also be enabled. For example, enabling M_CIRCLE_FIT will result in all the circle fit values of each edge to be calculated. This is equivalent to individually enabling each of the following: M_CIRCLE_FIT_CENTER_X, M_CIRCLE_FIT_CENTER_Y, M_CIRCLE_FIT_RADIUS, M_CIRCLE_FIT_ERROR, and M_CIRCLE_FIT_COVERAGE.

The features that belong to each group is typically self evident. For a description of each, see MedgeControl().