QQ登录

只需一步,快速开始

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)




回复

使用道具 举报

快速回复 返回列表 客服中心 搜索