工控编程吧

标题: halcon background_seg函数介绍 [打印本页]

作者: qq263946146    时间: 2019-5-14 00:52
标题: halcon background_seg函数介绍
background_seg(Foreground : BackgroundRegions : : )
background_seg确定前景区域Foreground的背景连接组件(components)。
此运算符通常在边缘运算符之后使用,以确定所提取的边缘所包围的区域。
采用4邻域法确定连接组件。
用代码模拟此句函数background_seg(Foreground,BackgroundRegions)
  complement(Foreground,Background)
  get_system('neighborhood',Save)
  set_system('neighborhood',4)
  connection(Background,BackgroundRegions)
     clear_obj(Background)
  set_system('neighborhood',Save)

gen_circle (Circle, 200, 200, 100.5)
background_seg (Circle, BackgroundRegions)
可以比较直观查看执行效果

例程
* 使用边缘滤波器进行分割
read_image(Image,'fabrik')
sobel_dir(Image,Sobel,Dir,'sum_sqrt',3)
threshold(Sobel,Edges,20,255)
skeleton(Edges,Margins)
background_seg(Margins,Regions)

又如:
read_image (Image, 'fabrik')
* Detect edges
sobel_amp (Image, EdgeAmplitude, 'thin_sum_abs', 3)
threshold (EdgeAmplitude, Edges, 5, 255)
background_seg (Edges, BackgroundRegions)
* Fill up holes in regions based on shape feature 'area'
fill_up_shape (BackgroundRegions, RegionFillUp, 'area', 1, 40)
dev_clear_window ()
dev_set_colored (6)
dev_display (RegionFillUp)









欢迎光临 工控编程吧 (https://www.gkbc8.com/) Powered by Discuz! X3.4