Skip to content

detect_edge_segmentsDetectEdgeSegmentsDetectEdgeSegmentsdetect_edge_segmentsT_detect_edge_segmentsπŸ”—

Short descriptionπŸ”—

detect_edge_segmentsDetectEdgeSegmentsDetectEdgeSegmentsdetect_edge_segmentsT_detect_edge_segments β€” Detect straight edge segments.

SignatureπŸ”—

detect_edge_segments( image Image, integer SobelSize, integer MinAmplitude, integer MaxDistance, integer MinLength, out line.begin.y BeginRow, out line.begin.x BeginCol, out line.end.y EndRow, out line.end.x EndCol )void DetectEdgeSegments( const HObject& Image, const HTuple& SobelSize, const HTuple& MinAmplitude, const HTuple& MaxDistance, const HTuple& MinLength, HTuple* BeginRow, HTuple* BeginCol, HTuple* EndRow, HTuple* EndCol )static void HOperatorSet.DetectEdgeSegments( HObject image, HTuple sobelSize, HTuple minAmplitude, HTuple maxDistance, HTuple minLength, out HTuple beginRow, out HTuple beginCol, out HTuple endRow, out HTuple endCol )def detect_edge_segments( image: HObject, sobel_size: int, min_amplitude: int, max_distance: int, min_length: int ) -> Tuple[Sequence[int], Sequence[int], Sequence[int], Sequence[int]]

Herror T_detect_edge_segments( const Hobject Image, const Htuple SobelSize, const Htuple MinAmplitude, const Htuple MaxDistance, const Htuple MinLength, Htuple* BeginRow, Htuple* BeginCol, Htuple* EndRow, Htuple* EndCol )

void HImage::DetectEdgeSegments( Hlong SobelSize, Hlong MinAmplitude, Hlong MaxDistance, Hlong MinLength, HTuple* BeginRow, HTuple* BeginCol, HTuple* EndRow, HTuple* EndCol ) const

void HImage.DetectEdgeSegments( int sobelSize, int minAmplitude, int maxDistance, int minLength, out HTuple beginRow, out HTuple beginCol, out HTuple endRow, out HTuple endCol )

DescriptionπŸ”—

detect_edge_segmentsDetectEdgeSegments detects straight edge segments in the gray image Imageimageimage. The extracted edge segments are returned as line segments with start point (BeginRowbeginRowbegin_row,BeginColbeginColbegin_col) and end point (EndRowendRowend_row,EndColendColend_col). Edge detection is based on the Sobel filter, using 'sum_abs'"sum_abs" as parameter and SobelSizesobelSizesobel_size as the filter mask size (see sobel_ampSobelAmp). Only pixels with a filter response larger than MinAmplitudeminAmplitudemin_amplitude are used as candidates for edge points. These thresholded edge points are thinned and split into straight segments. Due to technical reasons, edge points in which several edges meet are lost. Therefore, detect_edge_segmentsDetectEdgeSegments usually does not return closed object contours. The parameter MaxDistancemaxDistancemax_distance controls the maximum allowed distance of an edge point to its approximating line. For efficiency reasons, the sum of the absolute values of the coordinate differences is used instead of the Euclidean distance. MinLengthminLengthmin_length controls the minimum length of the line segments. Lines shorter than MinLengthminLengthmin_length are not returned.

AttentionπŸ”—

Note that filter operators may return unexpected results if an image with a reduced domain is used as input. Please refer to the chapter Filters.

Execution informationπŸ”—

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

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

  • Automatically parallelized on tuple level.

ParametersπŸ”—

Imageimageimage (input_object) (multichannel-)image(-array) β†’ object (byte)HObject (byte)HImage (byte)HObject (byte)Hobject (byte)

Input image.

SobelSizesobelSizesobel_size (input_control) integer β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Mask size of the Sobel operator.

Default: 55
List of values: 3, 5, 7, 9, 11, 133, 5, 7, 9, 11, 13

MinAmplitudeminAmplitudemin_amplitude (input_control) integer β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Minimum edge strength.

Default: 3232
Suggested values: 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 80, 90, 100, 11010, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 80, 90, 100, 110
Value range: 1 ≀ MinAmplitude ≀ 255
Minimum increment: 1
Recommended increment: 1

MaxDistancemaxDistancemax_distance (input_control) integer β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Maximum distance of the approximating line to its original edge.

Default: 33
Suggested values: 2, 3, 4, 5, 6, 7, 82, 3, 4, 5, 6, 7, 8
Value range: 0 ≀ MaxDistance
Minimum increment: 1
Recommended increment: 1

MinLengthminLengthmin_length (input_control) integer β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Minimum length of to resulting line segments.

Default: 1010
Suggested values: 3, 5, 7, 9, 11, 13, 16, 203, 5, 7, 9, 11, 13, 16, 20
Value range: 1 ≀ MinLength
Minimum increment: 1
Recommended increment: 1

BeginRowbeginRowbegin_row (output_control) line.begin.y-array β†’ (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Row coordinate of the line segments’ start points.

BeginColbeginColbegin_col (output_control) line.begin.x-array β†’ (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Column coordinate of the line segments’ start points.

EndRowendRowend_row (output_control) line.end.y-array β†’ (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Row coordinate of the line segments’ end points.

EndColendColend_col (output_control) line.end.x-array β†’ (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Column coordinate of the line segments’ end points.

ExampleπŸ”—

(C)

Htuple  SobelSize,MinAmplitude,MaxDistance,MinLength\;
Htuple  RowBegin,ColBegin,RowEnd,ColEnd\;

create_tuple(&SobelSize,1)\;
set_i(SobelSize,5,0)\;
create_tuple(&MinAmplitude,1)\;
set_i(MinAmplitude,32,0)\;
create_tuple(&MaxDistance,1)\;
set_i(MaxDistance,3,0)\;
create_tuple(&MinLength,1)\;
set_i(MinLength,10,0)\;
T_detect_edge_segments(Image,SobelSize,MinAmplitude,MaxDistance,MinLength,
                &RowBegin,&ColBegin,&RowEnd,&ColEnd)\;

ResultπŸ”—

detect_edge_segmentsDetectEdgeSegments returns 2 (H_MSG_TRUE) if all parameters are correct. If the input is empty the behavior can be set via set_system('no_object_result',<Result>). If necessary, an exception is raised.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

sigma_imageSigmaImage, median_imageMedianImage

Possible successors

partition_linesPartitionLines, line_positionLinePosition, line_orientationLineOrientation

Alternatives

sobel_ampSobelAmp, thresholdThreshold, skeletonSkeleton

ModuleπŸ”—

Foundation