38、表面检测---(热缩管划痕检测)
目标:检测下图热缩管表面是否刮伤受损。
Halcon Code:
*关闭窗口更新
dev_update_window ('off')
*读入图像
read_image (Image, '222.jpg')
*阈值分割提取感兴趣区域,减少图像处理区域
threshold (Image, Regions, 0, 86)
*填充
fill_up (Regions, RegionFillUp)
*腐蚀区域,忽略边缘影响
erosion_circle (RegionFillUp, RegionErosion, 15)
*剪裁图像
reduce_domain (Image, RegionErosion, ImageReduced)
*动态阈值分割,提取划痕
var_threshold (ImageReduced, Region, 30, 30, 0.6, 5, 'dark')
*连通性分析
connection (Region, ConnectedRegions)
*筛选区域
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 1971.39, 7154)
dev_display (Image)
dev_display (SelectedRegions)