Skip to content

measure_pairsMeasurePairsMeasurePairsmeasure_pairsT_measure_pairs🔗

Short description🔗

measure_pairsMeasurePairsMeasurePairsmeasure_pairsT_measure_pairs — Extract straight edge pairs perpendicular to a rectangle or annular arc.

Signature🔗

measure_pairs( image Image, measure MeasureHandle, number Sigma, number Threshold, string Transition, string Select, out point.y RowEdgeFirst, out point.x ColumnEdgeFirst, out real AmplitudeFirst, out point.y RowEdgeSecond, out point.x ColumnEdgeSecond, out real AmplitudeSecond, out real IntraDistance, out real InterDistance )void MeasurePairs( const HObject& Image, const HTuple& MeasureHandle, const HTuple& Sigma, const HTuple& Threshold, const HTuple& Transition, const HTuple& Select, HTuple* RowEdgeFirst, HTuple* ColumnEdgeFirst, HTuple* AmplitudeFirst, HTuple* RowEdgeSecond, HTuple* ColumnEdgeSecond, HTuple* AmplitudeSecond, HTuple* IntraDistance, HTuple* InterDistance )static void HOperatorSet.MeasurePairs( HObject image, HTuple measureHandle, HTuple sigma, HTuple threshold, HTuple transition, HTuple select, out HTuple rowEdgeFirst, out HTuple columnEdgeFirst, out HTuple amplitudeFirst, out HTuple rowEdgeSecond, out HTuple columnEdgeSecond, out HTuple amplitudeSecond, out HTuple intraDistance, out HTuple interDistance )def measure_pairs( image: HObject, measure_handle: HHandle, sigma: float, threshold: float, transition: str, select: str ) -> Tuple[Sequence[float], Sequence[float], Sequence[float], Sequence[float], Sequence[float], Sequence[float], Sequence[float], Sequence[float]]

Herror T_measure_pairs( const Hobject Image, const Htuple MeasureHandle, const Htuple Sigma, const Htuple Threshold, const Htuple Transition, const Htuple Select, Htuple* RowEdgeFirst, Htuple* ColumnEdgeFirst, Htuple* AmplitudeFirst, Htuple* RowEdgeSecond, Htuple* ColumnEdgeSecond, Htuple* AmplitudeSecond, Htuple* IntraDistance, Htuple* InterDistance )

void HMeasure::MeasurePairs( const HImage& Image, double Sigma, double Threshold, const HString& Transition, const HString& Select, HTuple* RowEdgeFirst, HTuple* ColumnEdgeFirst, HTuple* AmplitudeFirst, HTuple* RowEdgeSecond, HTuple* ColumnEdgeSecond, HTuple* AmplitudeSecond, HTuple* IntraDistance, HTuple* InterDistance ) const

void HMeasure::MeasurePairs( const HImage& Image, double Sigma, double Threshold, const char* Transition, const char* Select, HTuple* RowEdgeFirst, HTuple* ColumnEdgeFirst, HTuple* AmplitudeFirst, HTuple* RowEdgeSecond, HTuple* ColumnEdgeSecond, HTuple* AmplitudeSecond, HTuple* IntraDistance, HTuple* InterDistance ) const

void HMeasure::MeasurePairs( const HImage& Image, double Sigma, double Threshold, const wchar_t* Transition, const wchar_t* Select, HTuple* RowEdgeFirst, HTuple* ColumnEdgeFirst, HTuple* AmplitudeFirst, HTuple* RowEdgeSecond, HTuple* ColumnEdgeSecond, HTuple* AmplitudeSecond, HTuple* IntraDistance, HTuple* InterDistance ) const (Windows only)

void HImage::MeasurePairs( const HMeasure& MeasureHandle, double Sigma, double Threshold, const HString& Transition, const HString& Select, HTuple* RowEdgeFirst, HTuple* ColumnEdgeFirst, HTuple* AmplitudeFirst, HTuple* RowEdgeSecond, HTuple* ColumnEdgeSecond, HTuple* AmplitudeSecond, HTuple* IntraDistance, HTuple* InterDistance ) const

void HImage::MeasurePairs( const HMeasure& MeasureHandle, double Sigma, double Threshold, const char* Transition, const char* Select, HTuple* RowEdgeFirst, HTuple* ColumnEdgeFirst, HTuple* AmplitudeFirst, HTuple* RowEdgeSecond, HTuple* ColumnEdgeSecond, HTuple* AmplitudeSecond, HTuple* IntraDistance, HTuple* InterDistance ) const

void HImage::MeasurePairs( const HMeasure& MeasureHandle, double Sigma, double Threshold, const wchar_t* Transition, const wchar_t* Select, HTuple* RowEdgeFirst, HTuple* ColumnEdgeFirst, HTuple* AmplitudeFirst, HTuple* RowEdgeSecond, HTuple* ColumnEdgeSecond, HTuple* AmplitudeSecond, HTuple* IntraDistance, HTuple* InterDistance ) const (Windows only)

void HMeasure.MeasurePairs( HImage image, double sigma, double threshold, string transition, string select, out HTuple rowEdgeFirst, out HTuple columnEdgeFirst, out HTuple amplitudeFirst, out HTuple rowEdgeSecond, out HTuple columnEdgeSecond, out HTuple amplitudeSecond, out HTuple intraDistance, out HTuple interDistance )

void HImage.MeasurePairs( HMeasure measureHandle, double sigma, double threshold, string transition, string select, out HTuple rowEdgeFirst, out HTuple columnEdgeFirst, out HTuple amplitudeFirst, out HTuple rowEdgeSecond, out HTuple columnEdgeSecond, out HTuple amplitudeSecond, out HTuple intraDistance, out HTuple interDistance )

Description🔗

measure_pairsMeasurePairs serves to extract straight edge pairs which lie perpendicular to the major axis of a rectangle or annular arc.

For an explanation of the concept of 1D measuring see the introduction of chapter 1D Measuring.

The extraction algorithm of measure_pairsMeasurePairs is identical to measure_posMeasurePos. In addition the edges are grouped to pairs: If Transitiontransitiontransition = 'positive'"positive", the edge points with a dark-to-light transition in the direction of the major axis of the rectangle are returned in RowEdgeFirstrowEdgeFirstrow_edge_first and ColumnEdgeFirstcolumnEdgeFirstcolumn_edge_first. In this case, the corresponding edges with a light-to-dark transition are returned in RowEdgeSecondrowEdgeSecondrow_edge_second and ColumnEdgeSecondcolumnEdgeSecondcolumn_edge_second. If Transitiontransitiontransition = 'negative'"negative", the behavior is exactly opposite. If Transitiontransitiontransition = 'all'"all", the first detected edge defines the transition for RowEdgeFirstrowEdgeFirstrow_edge_first and ColumnEdgeFirstcolumnEdgeFirstcolumn_edge_first. I.e., dependent on the positioning of the measure object, edge pairs with a light-dark-light transition or edge pairs with a dark-light-dark transition are returned. This is suited, e.g., to measure objects with different brightness relative to the background.

If more than one consecutive edge with the same transition is found, the first one is used as a pair element. This behavior may cause problems in applications in which the threshold Thresholdthresholdthreshold cannot be selected high enough to suppress consecutive edges of the same transition. For these applications, a second pairing mode exists that only selects the respective strongest edges of a sequence of consecutive rising and falling edges. This mode is selected by appending '_strongest'"_strongest" to any of the above modes for Transitiontransitiontransition, e.g., 'negative_strongest'"negative_strongest". Finally, it is possible to select which edge pairs are returned. If Selectselectselect is set to 'all'"all", all edge pairs are returned. If it is set to 'first'"first", only the first of the extracted edge pairs is returned, while it is set to 'last'"last", only the last one is returned.

The extracted edges are returned as single points which lie on the major axis of the rectangle. The corresponding edge amplitudes are returned in AmplitudeFirstamplitudeFirstamplitude_first and AmplitudeSecondamplitudeSecondamplitude_second. In addition, the distance between each edge pair is returned in IntraDistanceintraDistanceintra_distance and the distance between consecutive edge pairs is returned in InterDistanceinterDistanceinter_distance. Here, IntraDistance[i] corresponds to the distance between EdgeFirst[i] and EdgeSecond[i], while InterDistance[i] corresponds to the distance between EdgeSecond[i] and EdgeFirst[i+1], i.e., the tuple InterDistanceinterDistanceinter_distance contains one element less than the tuples of the edge pairs.

Attention🔗

measure_pairsMeasurePairs 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. Additionally, Sigmasigmasigma must not become larger than approx. 0.5 * Length1 (for Length1 see gen_measure_rectangle2GenMeasureRectangle2).

It should be kept in mind that measure_pairsMeasurePairs ignores the domain of Imageimageimage for efficiency reasons. If certain regions in the image should be excluded from the measurement a new measure object with appropriately modified parameters should be generated.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

Imageimageimage (input_object) singlechannelimage → object (byte / uint2 / real)HObject (byte / uint2 / real)HImage (byte / uint2 / real)HObject (byte / uint2 / real)Hobject (byte / uint2 / real)

Input image.

MeasureHandlemeasureHandlemeasure_handle (input_control) measure → (handle)HTuple (HHandle)HMeasure, HTuple (IntPtr)HHandleHtuple (handle)

Measure object handle.

Sigmasigmasigma (input_control) number → (real)HTuple (double)HTuple (double)floatHtuple (double)

Sigma of gaussian smoothing.

Default: 1.01.0
Suggested values: 0.4, 0.6, 0.8, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 7.0, 10.00.4, 0.6, 0.8, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 7.0, 10.0
Value range: 0.4 ≤ Sigma ≤ 100 (lin)
Minimum increment: 0.01
Recommended increment: 0.1

Thresholdthresholdthreshold (input_control) number → (real)HTuple (double)HTuple (double)floatHtuple (double)

Minimum edge amplitude.

Default: 30.030.0
Suggested values: 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 90.0, 110.05.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 90.0, 110.0
Value range: 1 ≤ Threshold ≤ 255 (lin)
Minimum increment: 0.5
Recommended increment: 2

Transitiontransitiontransition (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Type of gray value transition that determines how edges are grouped to edge pairs.

Default: 'all'"all"
List of values: 'all', 'all_strongest', 'negative', 'negative_strongest', 'positive', 'positive_strongest'"all", "all_strongest", "negative", "negative_strongest", "positive", "positive_strongest"

Selectselectselect (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Selection of edge pairs.

Default: 'all'"all"
List of values: 'all', 'first', 'last'"all", "first", "last"

RowEdgeFirstrowEdgeFirstrow_edge_first (output_control) point.y-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Row coordinate of the center of the first edge.

ColumnEdgeFirstcolumnEdgeFirstcolumn_edge_first (output_control) point.x-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Column coordinate of the center of the first edge.

AmplitudeFirstamplitudeFirstamplitude_first (output_control) real-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Edge amplitude of the first edge (with sign).

RowEdgeSecondrowEdgeSecondrow_edge_second (output_control) point.y-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Row coordinate of the center of the second edge.

ColumnEdgeSecondcolumnEdgeSecondcolumn_edge_second (output_control) point.x-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Column coordinate of the center of the second edge.

AmplitudeSecondamplitudeSecondamplitude_second (output_control) real-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Edge amplitude of the second edge (with sign).

IntraDistanceintraDistanceintra_distance (output_control) real-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Distance between edges of an edge pair.

InterDistanceinterDistanceinter_distance (output_control) real-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Distance between consecutive edge pairs.

Result🔗

If the parameter values are correct the operator measure_pairsMeasurePairs returns the value 2 (H_MSG_TRUE). Otherwise an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

gen_measure_rectangle2GenMeasureRectangle2

Possible successors

close_measureCloseMeasure

Alternatives

edges_sub_pixEdgesSubPix, fuzzy_measure_pairsFuzzyMeasurePairs, fuzzy_measure_pairingFuzzyMeasurePairing

See also

measure_posMeasurePos, fuzzy_measure_posFuzzyMeasurePos

Module🔗

1D Metrology