【Halcon】区域分割:background_seg

有些事不是自己能把握,我们所能做的就是在拨开重重阻碍,寻得内心之所需、之所欲,义无反馈之前进。
人,还是需要一些执拗的! ——–Y忍冬草
————————————————————————————————————
1.算子
根据给定的轮廓利用4邻域来分割连通域:
background_seg(Foreground : BackgroundRegions : : )
2.理论
该算子经常应用于求取边缘轮廓之后,根据轮廓,通过4邻域来对连通区域分割。
该算子的返回值为2(H_MSG_TRU)。在空object输入的情况下,可以通过set_system(‘no_object_result’,’Result’)设置返回结果;在空region的输入情况下,可以通过set_system(‘empty_region_result’,’Result’)设置返回结果。如果需要,可以将异常抛出。
3.代码

 * Determine the connected components of the background of given regions
 * 
read_image (Image, 'fabrik')
 * 检测边缘
sobel_amp (Image, EdgeAmplitude, 'thin_sum_abs', 3)
threshold (EdgeAmplitude, Edges, 5, 255)
background_seg (Edges, BackgroundRegions)
 * 根据空洞面积进行填充
fill_up_shape (BackgroundRegions, RegionFillUp, 'area', 1, 40)
dev_clear_window ()
dev_set_colored (6)
dev_display (RegionFillUp)

4.结果

  • 边缘图
    这里写图片描述
  • 结果图
    这里写图片描述
    5.参考

  • Halcon官方帮助文档

猜你喜欢

转载自blog.csdn.net/y363703390/article/details/81194280
SEG