Measure Longest Edge Segment

Use this tool to measure longest edge segments.

They are returned as segment ROIs that can be used in the tools Measure Circle to Segment, Measure Segment to Point, and Measure Segment to Segment. The tool also returns the "Segment Length" and the "Segment Orientation" in relation to the virtual horizontal line. The tool is able to return a segment ROI even if the image does not contain a complete or smooth edge .

For this tool easyTouch and easyTouch+ are available. This means you may select the longest edge segment to be measured interactively in the image. Move the mouse over an edge whose longest segment is to be measured. MERLIC will display a preview of the suggested longest edge segment. If you want to measure the previewed segment, click on the edge to confirm the selection. The parameters are automatically adjusted to fit the selected segment. However, they still can be adjusted manually at the corresponding connectors.

Alternatively, you may use regions of interest (ROIs) for the measuring. Draw an ROI into the image. If the ROI contains edge segments that fit the current parameter settings, they are automatically determined and measured. Without an ROI the tool will look for the longest edge segment in the whole image as soon as an image is connected. The ROI also determines the start and end point and therefore the length of the edge. Use smaller ROIs to detect edges on a curved line.

Use the tool Measure Opposite Edges if you want to measure the total length of a line instead of the longest edge segment. The tool "Measure Longest Edge Segment" establishes an edge contour () that considers various factors like edge irregularities and therefore might not be identical to the edge you want to measure. The results are based on the longest segment () of the contour. Therefore the longest edge segment might be shorter or longer than the total length of the edge.

Parameters

Basic Parameters

Image:

This parameter represents the input image in which the longest edge segment is measured. If an image is available as a result of a previous tool, it is connected automatically and used as input image.

If a color image is used as input image for this tool, only the first channel, i.e., the red channel, is used for the processing.

Edge Contrast:

This parameter defines the contrast of the longest edge segment relative to the background. It is defined in gray values and set to 20 by default. When an edge segment is selected for the measuring, the "Edge Contrast" of this segment is instantly determined and adopted. If further edge segments are added using easyTouch+, the "Edge Contrast" is adjusted automatically with each edge segment that is added to the selection. However, you may also change its value manually at the corresponding connector.

Edge Width:

This parameter defines the width of the longest edge segment. It is defined in pixels and set to 2 px by default. When an edge segment is selected for the measuring, the "Edge Width" of this segment is instantly determined and adopted. If further edge segments are added using easyTouch+, the "Edge Width" is adjusted automatically with each segment that is added to the selection. However, you may also change its value manually at the corresponding connector.

Additional Parameters

ROI:

This parameter defines the region of interest (ROI) for processing. Image parts outside of the union of the ROI and "Processing Region" are not processed.In addition, if either of them is empty, the image part inside of the other one is processed. In case both of them are empty, the whole image is processed. However, if easyTouch is used to determine the parameters, only the "Processing Region" is used for the measuring.

By default the ROI is defined as an empty ROI. If you want to use a non-empty ROI for the processing, you either have to connect the parameter to an appropriate ROI result of a previous tool or you have to draw new ROIs into the image using the available ROI buttons.

The union of the defined "ROI" and the "Processing Region" is checked for an edge segment that fits to the current parameter settings, e.g., if the "Edge Transition" is set to "dark to light", the tool searches along the ROI orientation if there is an edge segment that changes from dark to light. If suitable edge segments are found, they are used for the measurement.

Calibration Data:

This parameter defines the calibration data needed for the correction of possible lens distortions and the position of the camera with respect to the image plane. By default no calibration data are defined. If you want to use calibration data, you have to connect the parameter to an appropriate result of a previous tool, e.g., Calibrate Camera, to make sure that the calibration data are transmitted to this tool. It will be instantly applied to the image.

In case "Calibration Data" are used for this tool, all results that represent pixel values will be automatically transformed to the corresponding world coordinates.

Alignment Data:

This parameter represents the alignment data that are used to align the ROI. By default no alignment data are connected and thus no effect is visible. If you want to use specific alignment data, you have to connect the parameter to an appropriate result of a previous tool such as Determine Alignment with Matching, Determine Alignment with Straight Border, Align Image, or Rotate Image.

Failed Measurement:

This parameter defines which value is returned in the result "Segment Length" and "Segment Orientation" in case no measurement could be performed. The parameter is set to "ignore" by default.You may set the parameter at the corresponding connector to the following values.

Value

Description

ignore

No value is returned if no measurement could be performed.

−1

−1 is returned if no measurement could be performed. You may replace it directly in the input field of the connector with any number or string you want to return.

*

* is returned if no measurement could be performed. You may replace it directly in the input field of the connector with any number or string you want to return.

Processing Region:

This parameter defines the region for processing. Image parts outside of the union of the ROI and "Processing Region" are not processed. In addition, if either of them is empty, the image part inside of the other one is processed. In case both of them are empty, the whole image is processed.

By default, "Processing Region" is defined as empty region. To specify a "Processing Region", you have to connect the parameter to an appropriate region result of a previous tool to make sure that a region is transmitted to this tool.

If easyTouch is used to determine the parameters, only the "Processing Region" is used for the measuring. In case the "Processing Region" is not defined, the whole image is used for the measuring.

Results

Basic Results

Segment:

This result returns the graphical representation of the longest edge segment that has been measured. The result is returned as a segment ROI. If more than one edge segments has been measured, "Segment" contains the ROIs of all longest edge segments.

Segment Length:

This result returns the length of the measured longest edge segment(s). The result is returned in pixels as a real number. In case "Calibration Data" is used, the length is returned in world coordinates. If more than one longest edge segment is measured, the corresponding lengths are returned in a tuple.

Segment Orientation:

This result returns the angle between the longest edge segment that has been measured and the virtual horizontal line through the center point of the segment. It is returned in degrees as a real number. The center point of the segment is the center of rotation. If the end point of the segment is above the horizontal axis, the angle (with positive sign) results from the rotation of the horizontal line in counterclockwise direction to the longest edge segment. If the end point is below the horizontal axis, the orientation (with negative sign) results from the rotation of the horizontal line in clockwise direction to the longest edge segment.

Tool State:

"Tool State" returns information about the state of the tool and thus can be used for error handling. Please see the topic Tool State Result for more information about the different tool state results.

Additional Results

Edge Contour:

This result returns the contour of the edge segment that has been used for the measurement.

Processing Time:

This result returns the duration of the most recent execution of the tool in milliseconds. The result is provided as additional result. Therefore, it is hidden by default but it can be displayed via the button beside the tool results. For more information see the section Processing Time in the tool reference overview.

Application Examples

This tool is used in the following MERLIC Vision App examples:

  • measure_distance_segment_circle_calibrated.mvapp