MmeasSetMarker()函数

Synopsis

Set a marker parameter.

Format

void MmeasSetMarker(MarkerId, ParamToSet, FirstValue, SecondValue)

MIL_ID MarkerId; Marker identifier
long ParamToSet; Parameter to set
double FirstValue; First value
double SecondValue; Second value or M_NULL

Description

This function sets a marker parameter (characteristic). Marker parameters are used in determining the marker(s) location in a target image. MmeasFindMarker locates the edge (or edges when searching for stripe marker) that best correspond to the specified marker’s characteristics. A marker’s parameters should describe the marker as accurately as possible to ensure that it will be successfully located in an image. See MmeasAllocMarker for the default values of these parameters.

The MarkerId parameter specifies the identifier of the marker.

The ParamToSet parameter specifies the type of parameter to set. The FirstValue and SecondValue parameters specify the values for the parameter being set. The FirstValue must always be provided. The SecondValue should only be provided when required; otherwise, it should be set to M_NULL.

The relative importance given to each of the parameters is crucial when locating a marker. The default behavior is to assign a weight of 50% to the strength of an edge and the remaining 50% to any other parameters not set to M_ANY (not considered). It is possible to force a different weight by adding M_WEIGHT_FACTOR to certain parameters and placing the percentage of importance in FirstValue. Note, the cumulative value of the weight factors must equal 100%. Parameters that can be weighted in this way are M_EDGE_STRENGTH, M_CONTRAST, M_POSITION, M_WIDTH, and M_EDGE_INSIDE.

Various marker parameters and their possible values can be set as shown in the following tables.

The ParamToSet, FirstValue and SecondValue parameters can be set to the following values:

ParamToSet Description Values
For point, edge, and stripe markers:
M_POSITION X and Y coordinates of the center of the marker in the target image (actual or approximate). Numerical values valid within the target image or M_ANY (default).
Set FirstValue to the X coordinate.
Set SecondValue to the Y coordinate.
M_POSITION_X X-coordinate of the marker in the target image (actual or approximate). Set FirstValue to a numerical value valid within the target image or M_ANY. Set SecondValue to M_NULL.
M_POSITION_Y Y-coordinate of the marker in the target image (actual or approximate). Set FirstValue to a numerical value valid within the target image or M_ANY. Set SecondValue to M_NULL.
M_POSITION_VARIATION The tolerance of position variation. Set FirstValue to a numerical value valid within the target image or M_ANY (default). Set SecondValue to M_NULL.
For stripe markers only:
M_POSITION_INSIDE_STRIPE The location of the given position (M_POSITION) relative to the stripe. Set FirstValue to:
M_YES if the position
is inside the stripe.
M_NO if the position is outside the stripe.
M_ANY if the position can
be either inside or outside the stripe.
Set SecondValue to M_NULL.
For edge and stripe markers:
M_ORIENTATION The orientation of an edge or stripe marker. Set FirstValue to:
M_VERTICAL (default) if the marker has a vertical orientation.
M_HORIZONTAL if the marker has a horizontal orientation.
M_ANY if the marker orientation is not known.
Set SecondValue to M_NULL.
M_POLARITY The polarity specifies whether an edge is a rising edge (increase in grayscale value) or a falling edge (decrease in grayscale value). M_POSITIVE: rising edge.
M_NEGATIVE: falling edge.
M_ANY: not a criteria.. (default for edges and first stripe edge)
M_OPPOSITE: the specified edge of a stripe marker has an opposite polarity to the other edge. (default for second stripe edge)
M_SAME: the specified edge of a stripe marker has the same polarity as the other edge.
When setting this parameter for an edge marker, set FirstValue to the polarity and SecondValue to M_NULL.
When setting this parameter for a stripe marker, set FirstValue to the polarity of the stripe marker’s first (from top-left) edge and set SecondValue to the polarity of its second edge.
M_CONTRAST Typical grayscale difference between an edge and its background. For a stripe marker the values should be the typical grayscale difference for each of its edges. Set FirstValue to a numerical value between 0 and the maximum value of the buffer (that is, 255 for an 8-bit buffer and 65535 for a 16-bit buffer) or to M_ANY (default).
Set SecondValue to M_NULL for an edge marker or to the appropriate value or M_ANY for the second edge of a stripe marker.
M_CONTRAST_VARIATION Used with M_CONTRAST, this parameter specifies the contrast variation of an edge marker. For a stripe marker, this value should be the average of the contrast variation for each of its edges. Set FirstValue to a numerical value between 0 and the maximum value of the buffer (that is, 255 for an 8-bit buffer and 65535 for a 16-bit buffer) or to M_ANY (default). Set SecondValue to M_NULL.
M_WIDTH Typical width of a stripe marker in pixels (i.e., the distance between the marker’s edges). Set FirstValue to a numerical value valid within the target image or M_ANY (default). Set SecondValue to M_NULL.
M_WIDTH_VARIATION Used with M_WIDTH, this parameter specifies the maximum variation (tolerance) of a stripe’s width. Set FirstValue to a numerical value valid within the target image or M_ANY (default). Set SecondValue to M_NULL.
M_EDGE_STRENGTH The maximum pixel value variation of the edge marker. Set FirstValue to a value between 0 and 100. This represents a percentage of the image buffer’s maximum possible value (for example, with an 8-bit image buffer, 50% is a 128 maximum pixel value variation). Set to M_ANY (default) to select the strongest edge value encountered in the search. Set SecondValue for second edge of a stripe or to M_NULL.
M_EDGE_STRENGTH_VARIATION Used with M_EDGE_STRENGTH, this parameter specifies
the tolerance of the maximum pixel value variation of the edge marker.
Set FirstValue to a value between 0 and 100. This represents a percentage of the image buffer’s maximum possible value (for example, with an 8-bit image buffer, 50% is a 128 maximum pixel value variation).
Default setting is M_ANY.
Set SecondValue to M_NULL.
M_EDGE_INSIDE Typical number of edges occurring inside a stripe marker. Set FirstValue to a numerical value or to M_ANY. Set SecondValue to M_NULL.
M_EDGE_INSIDE_VARIATION The maximum variation (tolerance) in the number of inside edges of a stripe. Set FirstValue to a numerical value or to M_ANY. Set SecondValue to M_NULL.
M_BOX_ORIGIN The X and Y-coordinates of the marker measurement box’s top-left corner. These coordinates are in relation to the top-left corner of the image. Numerical values valid within the target image or M_DEFAULT. Set FirstValue to the X coordinate; SecondValue to the Y coordinate. When M_DEFAULT is specified, the coordinate(s) [0, 0] of the target image’s top-left pixel are used.
M_BOX_SIZE The width and height of the marker measurement box. Numerical values valid within the target image or M_DEFAULT. Set FirstValue to the width and SecondValue to the height. When M_DEFAULT is specified, the target image’s width and/or height is used.
M_BOX_CENTER The X and Y-coordinates of the marker measurement box’s center. These coordinates are in relation to the top-left corner of the target image. Numerical values valid within the target image or M_DEFAULT. Set FirstValue to the X coordinate; SecondValue to the Y coordinate. When M_DEFAULT is specified, the target image’s corresponding center coordinate is used.
M_BOX_FIRST_CENTER The X and Y-coordinates of the marker measurement box’s first edge (from top-left corner of the image) center point. These coordinates are in relation to the top-left corner of the target image and are applicable only when the marker orientation is set to M_ANY. Numerical values valid within the target image or M_DEFAULT. Set FirstValue to the X coordinate; SecondValue to the Y coordinate. When M_DEFAULT is specified,
the target image’s corresponding first border center coordinate is used.
M_BOX_SECOND_CENTER The X and Y coordinates of the marker measurement box’s second (from top-left corner of the image) edge center point.
These coordinates are in relation to the top-left coordinates of the target image and are applicable only when the marker orientation is set to M_ANY.
Numerical values valid within the target image or M_DEFAULT. Set FirstValue to the X coordinate. Set SecondValue to the Y coordinate. When M_DEFAULT is specified as either the X or Y coordinate, the corresponding target image’s second border center coordinate is used.
M_BOX_ANGLE The angle of the marker measurement box.
Note, if set to M_ANY, the contents of the region of interest are analyzed to determine the angle of the marker.
Set FirstValue to a value from 0 to 360 degrees (default is 0) or to M_ANY.
Set SecondValue to M_NULL.
M_BOX_ANGLE_MODE Enable the use of multiple-angle search, as specified by the settings of other M_BOX_ANGLE… parameters. The angle with the highest match score is returned. Set FirstValue to M_ENABLE or M_DISABLE (default, search only at the angle specified by M_BOX_ANGLE).
Set SecondValue to M_NULL.
M_BOX_ANGLE_DELTA_NEG
and
M_BOX_ANGLE_DELTA_POS
The range of angles to be searched for the marker: from (M_BOX_ANGLE – M_BOX_ANGLE_DELTA_NEG) to (M_BOX_ANGLE + M_BOX_ANGLE_DELTA_POS) inclusively, starting with an angle close to that of M_BOX_ANGLE. Set FirstValue to a value from 0.1 to 360 degrees or to M_DEFAULT (default of 180° for a symmetrical stripe marker, 360° for an edge marker or non-symmetrical stripe marker).
Set SecondValue to M_NULL.
M_BOX_ANGLE_TOLERANCE The rotation tolerance of the marker. This is the maximum angle at which a rotated marker can be found and still meet the acceptance level. Set FirstValue to a value from 0.1 to 360 degrees or
to M_DEFAULT (5.0°).
Set SecondValue to M_NULL.
M_BOX_ANGLE_ACCURACY The desired precision for the resulting angle of the marker. Set FirstValue to a value from 0.1 to 180 degrees or
to M_DISABLE to force an angle of accuracy equal to the angle of tolerance.
Set SecondValue to M_NULL.
M_BOX_ANGLE_INTERPOLATION_MODE The type of interpolation used when M_BOX_ANGLE_MODE is enabled. Set FirstValue to M_NEAREST_NEIGHBOR (no interpolation), M_BILINEAR (default), or M_BICUBIC.
M_BOX_ANGLE_REFERENCE The center of rotation used when M_BOX_ANGLE is not zero. Set FirstValue to M_BOX_CENTER (default) or M_BOX_ORIGIN.
M_EDGE_THRESHOLD The threshold beneath which a grayscale variation is not considered an edge. Set FirstValue to a value between 0.0 and 100.0 or M_DEFAULT (2.0).
The value represents a percentage of the maximum grayscale value permissible in the target image buffer.*
* For example, with a value of 2.0, a grayscale variation is considered an edge only if it is greater than 2% of the maximum value of the buffer multiplied by the box size.
To consider all grayscale variation as edges, irrespective of their values, set FirstValue to 0.0. However, due to the increased number of edges, MmeasFindMarker will execute relatively slowly.
M_MARKER_REFERENCE The X and Y-offsets of the marker’s reference position in relation to the marker’s center. Numerical values valid within the target image or M_DEFAULT. Set FirstValue to the X offset and SecondValue to the
Y offset. M_DEFAULT corresponds to the marker center (i.e., X-offset = 0 and Y-offset = 0).
For weighting purposes only:
M_WEIGHT_FACTOR+M_EDGE_STRENGTH
or
M_WEIGHT_FACTOR+M_CONTRAST
or
M_WEIGHT_FACTOR+M_POSITION
or
M_WEIGHT_FACTOR+M_WIDTH
or
M_WEIGHT_FACTOR+M_EDGE_INSIDE
Add a specific weight to the specified parameter. The value assigned to each parameter represents the percentage of weight assigned to that parameter. The sum of values of the M_WEIGHT_FACTOR+M… parameters must be 100.

See also

MmeasAllocMarker, MmeasFindMarker, MmeasGetResult

《MmeasSetMarker()函数》上有32条评论

评论已关闭。