Halcon的提取中心线算法

Halcon提取中心线的一般流程:

read_image (Image, 'C:/Users/Administrator/Desktop/china.png')
*计算提线参数
MaxLineWidth := 5
Contrast := 10
calculate_lines_gauss_parameters (MaxLineWidth, [Contrast,0], Sigma, Low, High)
*提取中心线
lines_gauss (Image, Lines, Sigma, Low, High, 'light', 'true', 'parabolic', 'true')
*合并共直线线段
union_collinear_contours_xld (Lines, UnionContours, 10, 1, 10, rad(30), 'attr_keep')
*按长度筛选线段
select_contours_xld (UnionContours, SelectedContours, 'contour_length', 20, 999999, -0.5, 0.5)
*显示结果
dev_display (Image)
dev_set_color ('red')
dev_display (SelectedContours)

MaxLineWidth = 5,Contract = 10,由于最大线宽太小,较宽线区域会生成多条中心线:

MaxLineWidth = 20,Contract = 10,线宽设置合理,生成的中心线比较居中:

MaxLineWidth = 40,Contract = 10,最大线宽过大,部分不够亮的区域未生成中心线:

MaxLineWidth = 40,Contract = 255,最大对比度时,不够亮的区域不会生成中心线:

 

posted @ 2022-09-12 11:19  广阔之海  阅读(1023)  评论(0编辑  收藏  举报