HALCON示例程序novelty_detection_dyn_threshold.hdev纱网缺陷检测
示例程序源码(加注释)
- 关于显示类函数解释
dev_update_window (‘off’)
read_image (Image, ‘plastic_mesh/plastic_mesh_01’)
dev_close_window ()
get_image_size (Image, Width, Height)
dev_open_window_fit_image (Image, 0, 0, Width, Height, WindowHandle)
set_display_font (WindowHandle, 18, ‘mono’, ‘true’, ‘false’)
dev_set_draw (‘margin’)
dev_set_line_width (3)
for J := 1 to 14 by 1
read_image (Image, 'plastic_mesh/plastic_mesh_' + J$'02')
* 动态阈值分割
mean_image (Image, ImageMean, 49, 49)
dyn_threshold (Image, ImageMean, RegionDynThresh, 5, 'dark')
* 分割连通域
connection (RegionDynThresh, ConnectedRegions)
* 使用面积进行区域筛选
select_shape (ConnectedRegions, ErrorRegions, 'area', 'and', 500, 99999)
count_obj (ErrorRegions, NumErrors)
dev_display (Image)
dev_set_color ('red')
dev_display (ErrorRegions)
if (NumErrors > 0)
disp_message (WindowHandle, 'Mesh not OK', 'window', 24, 12, 'black', 'true')
else
disp_message (WindowHandle, 'Mesh OK', 'window', 24, 12, 'black', 'true')
endif
if (J < 14)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
endif
endfor
处理思路
这个例子是主要讲解了动态阈值在缺陷检测中的应用。
后记
大家有什么问题可以向我提问哈,我看到了第一时间回复,希望在学习的路上多多结交良师益友。