halcon边缘检测-close_edges_length.hev

close_edges_length(Edges, Gradient : ClosedEdges : MinAmplitude, MaxGapLength : )

close_edges_length closes gaps in the output of an edge detector, and thus tries to produce complete object contours. This operator expects as input the edges (Edges) and amplitude image (Gradient) returned by typical edge operators, such as edges_image or sobel_amp.

Contours are closed in two steps: First, one pixel wide gaps in the input contours are closed, and isolated points are eliminated. After this, open contours are extended by up to MaxGapLength points by adding edge points until either the contour is closed or no more significant edge points can be found. A gradient is regarded as significant if it is larger than MinAmplitude. The neighboring points examined as possible new edge points are the point in the direction of the contour and its two adjacent points in an 8-neighborhood. For each of these points, the sum of its gradient and the maximum gradient of that points three possible neighbors is calculated (look ahead of length 1). The point with the maximum sum is then chosen as the new edge point

close_edges_length关闭边缘检测器输出中的间隙,从而尝试生成完整的对象轮廓。此运算符期望由典型的边运算符(例如edges_image或sobel_amp)返回的边(边)和幅度图(梯度)作为输入。

轮廓分两步关闭:首先,输入轮廓中的一个像素宽的间隙被关闭,并且消除了孤立点。在此之后,通过添加边缘点将开放轮廓延伸至MaxGapLength点,直到轮廓关闭或找不到更重要的边缘点。如果梯度大于MinAmplitude,则认为梯度是重要的。作为可能的新边缘点检查的相邻点是轮廓方向上的点及其在8邻域中的两个相邻点。对于这些点中的每一个,计算其梯度和指向三个可能邻居的最大梯度的总和(向前看长度1)。然后选择具有最大总和的点作为新的边缘点

read_image (Image, 'fabrik')
get_image_size (Image, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width, Height, 'black', WindowID)
sobel_amp (Image, EdgeAmplitude, 'thin_sum_abs', 3)
threshold (EdgeAmplitude, Edges, 30, 255)
close_edges_length (Edges, EdgeAmplitude, ClosedEdges, 8, 100)
dev_set_color ('green')
dev_display (ClosedEdges)
dev_set_color ('red')
dev_display (Edges)

原图 

sobel算子

阈值分割

 

close_edges_length

猜你喜欢

转载自blog.csdn.net/qq_29407397/article/details/86502061