halcon边缘检测-close_edges.hev

close_edges(Edges, EdgeImage : RegionResult : MinAmplitude : )

close_edges closes gaps in the output of an edge detector, and thus tries to produce complete object contours. This is done by examining the neighbors of each edge point to determine the point with maximum amplitude (i.e., maximum gradient), and adding the point to the edge if its amplitude is larger than the minimum amplitude passed in MinAmplitude. This operator expects as input the edges (Edges) and amplitude image (EdgeImage) returned by typical edge operators, such as edges_image or sobel_amp. close_edges does not take into account the edge directions that may be returned by an edge operator. Thus, in areas where the gradient is almost constant the edges may become rather “wiggly.”

close_edges关闭边缘检测器输出中的间隙,从而尝试生成完整的对象轮廓。 这是通过检查每个边缘点的邻居来确定具有最大幅度(即最大梯度)的点,并且如果其幅度大于在MinAmplitude中传递的最小幅度,则将该点添加到边缘。 此运算符期望由典型的边运算符(例如edges_image或sobel_amp)返回的边(Edges)和幅度图(EdgeImage)作为输入。 close_edges不考虑边缘运算符可能返回的边缘方向。 因此,在梯度几乎恒定的区域中,边缘可能变得相当“摇摆”。

read_image (Image, 'fabrik')
dev_close_window ()
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowID)
sobel_amp (Image, EdgeAmplitude, 'thin_sum_abs', 3)
threshold (EdgeAmplitude, Edges, 30, 255)
close_edges (Edges, EdgeAmplitude, EdgesExtended, 15)
dev_set_color ('green')
dev_display (EdgesExtended)
dev_set_color ('red')
dev_display (Edges)

下图的红色部分是经过sobel和阈值分割的。绿色部分是经过close_edges得到的。 

猜你喜欢

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