做美食的网站,大庆做网站的公司,行业网站开发公司,忻州网站建设费用HALCON示例程序particle.hdev测量小圆部分
示例程序源码#xff08;加注释#xff09;
关于显示类函数解释 dev_update_off () dev_close_window () dev_open_window (0, 0, 512, 512, ‘black’, WindowID) set_display_font (WindowID, 14, ‘mono’, ‘true’, ‘false’…HALCON示例程序particle.hdev测量小圆部分
示例程序源码加注释
关于显示类函数解释 dev_update_off () dev_close_window () dev_open_window (0, 0, 512, 512, ‘black’, WindowID) set_display_font (WindowID, 14, ‘mono’, ‘true’, ‘false’) read_image (Image, ‘particle’) dev_display (Image) disp_message (WindowID, ‘Original image’, ‘window’, 12, 12, ‘black’, ‘true’) disp_continue_message (WindowID, ‘black’, ‘true’) stop ()二值化 threshold (Image, Large, 110, 255)使用圆形膨胀区域 dilation_circle (Large, LargeDilation, 7.5) dev_display (Image) dev_set_draw (‘margin’) dev_set_line_width (3) dev_set_color (‘red’) dev_display (LargeDilation) dev_set_draw (‘fill’) disp_message (WindowID, ‘Exclude large areas from processing’, ‘window’, 12, 12, ‘black’, ‘true’) disp_continue_message (WindowID, ‘black’, ‘true’) stop ()求取区域补集 complement (LargeDilation, NotLarge)缩减定义域 reduce_domain (Image, NotLarge, ParticlesRed)动态阈值分割 mean_image (ParticlesRed, Mean, 31, 31) dyn_threshold (ParticlesRed, Mean, SmallRaw, 3, ‘light’)使用圆形元素开运算 opening_circle (SmallRaw, Small, 2.5)分割连通域 connection (Small, SmallConnection) dev_display (Image) dev_set_colored (12) dev_display (SmallConnection) disp_message (WindowID, ‘Extracted small particles’, ‘window’, 12, 12, ‘black’, ‘true’) disp_continue_message (WindowID, ‘black’, ‘true’) stop () dev_set_color (‘green’) dev_display (Image) dev_set_draw (‘margin’) dev_display (SmallConnection) Button : 1以下代码块完成了鼠标点击到某区域得到区域的面积
while (Button 1)disp_message (WindowID, [Select object with left mouse button,Right button to quit], image, 5, 5, black, true)dev_set_color (green)* 获取鼠标左键点击坐标get_mbutton (WindowID, Row, Column, Button)dev_display (Image)dev_display (SmallConnection)dev_set_color (red)* 使用点坐标筛选区域select_region_point (SmallConnection, SmallSingle, Row, Column)dev_display (SmallSingle)count_obj (SmallSingle, NumSingle)if (NumSingle 1)* 求区域平均灰度值intensity (SmallSingle, Image, MeanGray, DeviationGray)area_center (SmallSingle, Area, Row, Column)disp_message (WindowID, [Area Area,Intensity MeanGray$.3], image, Row 10, Column - 90, black, true)endif
endwhiledev_set_line_width (1) dev_update_on ()
处理思路
这个例子是主要讲解了通过鼠标实时显示区域特征的例子。
后记
大家有什么问题可以向我提问哈我看到了第一时间回复希望在学习的路上多多结交良师益友。