Herror ::measure_pos (
    Hobject Image,
    const HTuple &MeasureHandle,
    const HTuple &Sigma,
    const HTuple &Threshold,
    const HTuple &Transition,
    const HTuple &Select,
    HTuple *RowEdge,
    HTuple *ColumnEdge,
    HTuple *Amplitude,
    HTuple *Distance
)
HTuple HImage::MeasurePos (
    const HTuple &MeasureHandle,
    const HTuple &Sigma,
    const HTuple &Threshold,
    const HTuple &Transition,
    const HTuple &Select,
    HTuple *ColumnEdge,
    HTuple *Amplitude,
    HTuple *Distance
) const

Extract straight edges perpendicular to a rectangle.

::measure_pos extracts straight edges which lie perpendicular to the major axis of a rectangle.

The algorithm works by averaging the gray values in ``slices'' perpendicular to the major axis of the rectangle in order to obtain a one-dimensional edge profile. The sampling is done at subpixel positions in the image Image at integer row and column distances (in the coordinate frame of the rectangle) from the center of the rectangle. Since this involves some calculations which can be used repeatedly in several mesurements, the operator ::gen_measure_rectangle2 is used to perform these calculations only once, and thus to increase the speed of ::measure_pos significantly. Since there is a trade-off between accuracy and speed in the subpixel calculations of the gray values, and thus in the accuracy of the extracted edge positions, different interpolation schemes can be selected in ::gen_measure_rectangle2. (The interpolation only influences rectangles not aligned with the image axes.) The measure object generated with ::gen_measure_rectangle2 is passed in MeasureHandle.

After the one-dimensional edge profile has been calculated, subpixel edge locations are computed by convolving the profile with the derivatives of a Gaussian smoothing kernel of standard deviation Sigma. Salient edges can be selected with the parameter Threshold, which constitutes a thresold on the amplitude, i.e., the absolute value of the first derivative, of the edge. Additionally, it is possible to select only positive edges, i.e., edges which constitute a dark-to-light transition in the direction of the major axis of the rectangle (Transition = 'positive'), only negative edges, i.e., light-to-dark transitions (Transition = 'negative'), or both types of edges (Transition = 'all'). Finally, it is possible to select which edge points are returned. If Select is set to 'all', all edge points are returned. If it is set to 'first', only the first of the extracted edge points is returned, while it is set to 'last', only the last one is returned.

The extracted edges are returned as single points which lie on the major axis of the rectangle in (RowEdge,ColumnEdge). The corresponding edge amplitudes are returned in Amplitude. In addition, the distance between consecutive edge points is returned in Distance. Here, Distance[i] corresponds to the distance between Edge[i] and Edge[i+1], i.e., the tuple Distance contains one element less than the tuples RowEdge and ColumnEdge.


Attention

::measure_pos only returns meaningful results if the assumptions that the edges are straight and perpendicular to the major axis of the rectangle are fulfilled. Thus, it should not be used to extract edges from curved objects, for example. Furthermore, the user should ensure that the rectangle is as close to perpendicular as possible to the edges in the image.


Parameters

Image (input_object)
singlechannelimage -> Hobject: HImage ( byte )
Input image.

MeasureHandle (input_control)
measure_id -> HTuple.long
Measure object handle.

Sigma (input_control)
number -> HTuple.double
Sigma of gaussian smoothing.
Default value: 1.0
Suggested values: 0.4, 0.6, 0.8, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 7.0, 10.0
Typical range of values: 0.4 <= Sigma <= 100 (lin)
Minimum increment: 0.01
Recommended increment: 0.1
Restriction: Sigma >= 0.4

Threshold (input_control)
number -> HTuple.double
Minimum edge amplitude.
Default value: 30.0
Suggested values: 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 90.0, 110.0
Typical range of values: 1 <= Threshold <= 255 (lin)
Minimum increment: 2
Recommended increment: 0.5

Transition (input_control)
string -> HTuple.char *
Light/dark or dark/light edge.
Default value: 'all'
List of values: 'all', 'positive', 'negative'

Select (input_control)
string -> HTuple.char *
Selection of end points.
Default value: 'all'
List of values: 'all', 'first', 'last'

RowEdge (output_control)
point.y-array -> HTuple.double *
Row coordinate of the center of the edge.

ColumnEdge (output_control)
point.x-array -> HTuple.double *
Column coordinate of the center of the edge.

Amplitude (output_control)
real-array -> HTuple.double *
Edge amplitude of found edges (with sign).

Distance (output_control)
real-array -> HTuple.double *
Distance between consecutive edges.


Result

If the parameter values are correct the operator ::measure_pos returns the value H_MSG_TRUE. Otherwise an exception handling is raised.


Possible Predecessors

::gen_measure_rectangle2


Possible Successors

::close_measure


Alternatives

::edges_sub_pix, ::measure_pairs


Module

Sub-pixel operators



Copyright © 1996-2002 MVTec Software GmbH