Measure Longest Line Segment
Use this tool to measure longest line 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 line and regardless if the line is light on a dark background or vice versa.
For this tool easyTouch and easyTouch+ are available. This means you may select the longest line segment to be measured interactively in the image while the corresponding parameters are automatically adapted. Move the mouse over a line whose longest segment is to be measured. MERLIC will display a preview of the suggested longest line segment. If you want to measure the previewed segment, click on the line 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 line segments that fit the current parameter settings, they are automatically determined and measured. Without an ROI the tool will look for the longest line segment in the whole image as soon as an image is connected.
Use the tool Measure Opposite Edges if you want to measure the total length of a line instead of the longest line segment. The tool "Measure Longest Line Segment" establishes a line contour (
) that considers various factors like line irregularities and therefore might not be identical to the line you want to measure. The results are based on the longest segment (
) of the contour. Therefore the longest line segment might be shorter or longer than the total length of the line.
Parameters
Basic Parameters
Image:
This parameter represents the input image in which the longest line segment is measured.
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.
Line Width:
This parameter defines the width of the longest line segment. It is defined in pixels and set to 2 px by default. When a line segment is selected for the measuring, the "Line Width" of this segment is instantly determined and adopted. If further line segments are added to the selection using easyTouch+, the "Line Width" is adjusted automatically according to the line segment that is added to the selection. However, you may also change its value manually at the corresponding connector.
Line Contrast:
This parameter defines the contrast of the line segment relative to the background. It is defined in pixels and set to 20 px by default. When a line segment is selected for the measuring, the "Line Contrast" of this segment is instantly determined and adopted. If further line segments are added using easyTouch+, the "Line Contrast" is adjusted automatically with each line segment that is added to the selection. However, you may also change its value manually at the corresponding connector.
Line Property:
This parameter defines the transition property of the line segment. It is set to "dark" by default. When a line segment is selected for measuring, the "Line Property" is instantly determined and adjusted automatically for each line segment that is added to the selection.
|
Value |
Description |
|---|---|
|
light |
The longest line segment is light on a dark background, i.e., the gray values of the line segment are higher than the gray values of the background. If this value is set, only line segments with this transition property are measured. Other line segments are excluded from the measurement. |
|
dark |
The longest line segment is dark on a light background, i.e., the gray values of the line segment are lower than the gray values of the background. If this value is set, only line segments with this property are measured. Other line segments are excluded from the measurement. |
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.
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.
When the union of the defined "ROI" and the "Processing Region" is checked for a line 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 a line segment that changes from dark to light. If suitable line segments are found, they are used for the measurement.
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.
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.
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.
Results
Basic Results
Segment:
This result returns the graphical representation of the longest line segment that has been measured. The result is returned as a segment ROI . If more than one line segment has been measured, "Segment" contains the ROIs of all longest line segments.
Segment Length:
This result returns the length of the measured longest line 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 line segment is measured, the corresponding lengths are returned in a tuple.
Segment Orientation:
This result returns the angle between the longest line 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 counter clockwise direction to the longest line 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 line 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
Segment Contour:
This result returns the contour of the line 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.