halcon例程学习笔记(7)---检测漏焊board.hdev
2013-10-09 17:11
246 查看
通过本例程学习,掌握了read_image读取多幅图像,channels_to_image算子的使用。
本例程的算法思路是通过求取各个通道求取暗的和亮的部分,然后各个通道使用union1进行联合,得到的联合后的暗图像和明亮图像,然后求取明暗图像的交集。
后续经过基本的选择处理,得到漏焊的焊点。
*
get_system ('clip_region', Information)
set_system ('clip_region', 'true')
dev_update_window ('off')
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowID)
*读取四副图像
read_image (Images, ['ic0','ic1','ic2','ic3'])
*变为多通道图像
channels_to_image (Images, Ic)
*选择一个通道图像
select_obj (Images, Input1, 1)
dev_display (Input1)
set_display_font (WindowID, 14, 'mono', 'false', 'false')
disp_continue_message (WindowID, 'black', 'true')
stop ()
select_obj (Images, Input2, 2)
dev_display (Input2)
disp_continue_message (WindowID, 'black', 'true')
stop ()
select_obj (Images, Input3, 3)
dev_display (Input3)
disp_continue_message (WindowID, 'black', 'true')
stop ()
select_obj (Images, Input4, 4)
dev_display (Input4)
disp_continue_message (WindowID, 'black', 'true')
stop ()
*获取4个通道的均值图像
mean_n (Ic, ImageMean)
dev_display (ImageMean)
*阈值取暗的部分
threshold (Images, Darks, 0, 40)
union1 (Darks, Dark)
fill_up (Dark, DarkFilled)
dev_set_color ('green')
dev_display (DarkFilled)
disp_continue_message (WindowID, 'black', 'true')
stop ()
threshold (Images, Lights, 100, 255)
union1 (Lights, Light)
*求取暗的和亮的交集
intersection (DarkFilled, Light, Intersection)
dev_display (ImageMean)
dev_display (Intersection)
disp_continue_message (WindowID, 'black', 'true')
stop ()
*求取补集
complement (DarkFilled, Back)
dev_set_color ('red')
dev_display (Back)
disp_continue_message (WindowID, 'black', 'true')
stop ()
dev_clear_window()
dev_display (Intersection)
dev_clear_window()
dev_display (Back)
dev_clear_window()
expand_region (Intersection, Back, RegionExpanded, 10, 'image')
dev_clear_window()
dev_display (RegionExpanded)
fill_up (RegionExpanded, Good)
dev_display (ImageMean)
dev_set_color ('green')
dev_display (Good)
disp_continue_message (WindowID, 'black', 'true')
stop ()
*求取两个区域的差异
difference (DarkFilled, Good, Rest)
dev_set_color ('red')
dev_clear_window()
dev_display (Rest)
disp_continue_message (WindowID, 'black', 'true')
stop ()
*填充空白区域或者重叠区域的区域
expand_gray (Rest, Ic, Good, Bad, 6, 'image', 5)
dev_clear_window()
dev_display (Bad)
disp_continue_message (WindowID, 'black', 'true')
stop ()
connection (Bad, ConnectedBad)
select_shape (ConnectedBad, BigBad, 'area', 'and', 150, 99999)
area_center (BigBad, AreaBad, Row, Column)
count_obj (BigBad, NumMissingSolder)
AreaMissingSolder := sum(AreaBad)
dev_display (Images)
dev_set_color ('green')
dev_set_draw ('margin')
dev_set_line_width (3)
dev_display (Good)
dev_set_color ('red')
dev_display (BigBad)
dev_set_draw ('fill')
dev_set_line_width (1)
dev_update_window ('on')
set_system ('clip_region', Information)
本例程的算法思路是通过求取各个通道求取暗的和亮的部分,然后各个通道使用union1进行联合,得到的联合后的暗图像和明亮图像,然后求取明暗图像的交集。
后续经过基本的选择处理,得到漏焊的焊点。
*
get_system ('clip_region', Information)
set_system ('clip_region', 'true')
dev_update_window ('off')
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowID)
*读取四副图像
read_image (Images, ['ic0','ic1','ic2','ic3'])
*变为多通道图像
channels_to_image (Images, Ic)
*选择一个通道图像
select_obj (Images, Input1, 1)
dev_display (Input1)
set_display_font (WindowID, 14, 'mono', 'false', 'false')
disp_continue_message (WindowID, 'black', 'true')
stop ()
select_obj (Images, Input2, 2)
dev_display (Input2)
disp_continue_message (WindowID, 'black', 'true')
stop ()
select_obj (Images, Input3, 3)
dev_display (Input3)
disp_continue_message (WindowID, 'black', 'true')
stop ()
select_obj (Images, Input4, 4)
dev_display (Input4)
disp_continue_message (WindowID, 'black', 'true')
stop ()
*获取4个通道的均值图像
mean_n (Ic, ImageMean)
dev_display (ImageMean)
*阈值取暗的部分
threshold (Images, Darks, 0, 40)
union1 (Darks, Dark)
fill_up (Dark, DarkFilled)
dev_set_color ('green')
dev_display (DarkFilled)
disp_continue_message (WindowID, 'black', 'true')
stop ()
threshold (Images, Lights, 100, 255)
union1 (Lights, Light)
*求取暗的和亮的交集
intersection (DarkFilled, Light, Intersection)
dev_display (ImageMean)
dev_display (Intersection)
disp_continue_message (WindowID, 'black', 'true')
stop ()
*求取补集
complement (DarkFilled, Back)
dev_set_color ('red')
dev_display (Back)
disp_continue_message (WindowID, 'black', 'true')
stop ()
dev_clear_window()
dev_display (Intersection)
dev_clear_window()
dev_display (Back)
dev_clear_window()
expand_region (Intersection, Back, RegionExpanded, 10, 'image')
dev_clear_window()
dev_display (RegionExpanded)
fill_up (RegionExpanded, Good)
dev_display (ImageMean)
dev_set_color ('green')
dev_display (Good)
disp_continue_message (WindowID, 'black', 'true')
stop ()
*求取两个区域的差异
difference (DarkFilled, Good, Rest)
dev_set_color ('red')
dev_clear_window()
dev_display (Rest)
disp_continue_message (WindowID, 'black', 'true')
stop ()
*填充空白区域或者重叠区域的区域
expand_gray (Rest, Ic, Good, Bad, 6, 'image', 5)
dev_clear_window()
dev_display (Bad)
disp_continue_message (WindowID, 'black', 'true')
stop ()
connection (Bad, ConnectedBad)
select_shape (ConnectedBad, BigBad, 'area', 'and', 150, 99999)
area_center (BigBad, AreaBad, Row, Column)
count_obj (BigBad, NumMissingSolder)
AreaMissingSolder := sum(AreaBad)
dev_display (Images)
dev_set_color ('green')
dev_set_draw ('margin')
dev_set_line_width (3)
dev_display (Good)
dev_set_color ('red')
dev_display (BigBad)
dev_set_draw ('fill')
dev_set_line_width (1)
dev_update_window ('on')
set_system ('clip_region', Information)
相关文章推荐
- halcon例程学习笔记(10)---图像灰度共生矩阵cooc_feature_image.hdev
- halcon例程学习笔记(10)---图像灰度共生矩阵cooc_feature_image.hdev
- halcon例程学习笔记(8)---瓶子编号识别bottle2.hdev
- halcon例程学习笔记(2)----check_smd_tilt.hdev
- halcon例程学习笔记(6)----车道线快速检测autobahn
- halcon学习笔记之(一)label_word_process_mlp.hdev
- Halcon学习笔记-例程精析-Blob-Bottle
- Halcon例程学习:adaption_ocv.hev(光学字符检测)
- halcon例程学习笔记(11) 一维码、二维码识别
- detect_indent_fft.hdev相关例程学习(检测凹痕)
- Halcon学习笔记之缺陷检测(二)
- detect_indent_fft.hdev相关例程学习(检测凹痕)
- Halcon学习笔记之缺陷检测(布匹、皮革、塑料)
- halcon例程学习笔记(4)---count_fish_sticks.hdev基本函数使用
- measure_diamond.hdev检测钻石底尖的 相关例程学习
- measure_ball_bond.hdev普通的焊点检测,也就是找两个圆黑洞 相关例程学习
- optimize_aop.hdev对sobel边缘检测算子 AOP的对不同大小图像并行加速效果 相关例程学习
- measure_fill_level.hdev水平线到位检测 相关例程学习
- Halcon学习笔记之缺陷检测(一)
- interest_points_comparison.hdev不同检测感兴趣点的算法比较 相关例程学习