Blob分析---ball.hdev

目录

程序源码

1、dev_update_window ('off')

2、dev_close_window ()

3、read_image (Bond, 'die/die_03')

4、get_image_size(Bond, Width, Height)

5、dev_open_window_fit_image(Bond, 0, 0, -1, -1, WindowID)

6、dev_display (Bond)

7、set_display_font (WindowID, 14, 'mono', 'true', 'false')

8、disp_continue_message (WindowID, 'black', 'true')

9、threshold (Bond, Bright, 100, 255)

10、shape_trans (Bright, Die, 'rectangle2')

11、dev_set_color ('green')

12、dev_set_line_width (3)

13、dev_set_draw ('margin')

14、reduce_domain (Bond, Die, DieGrey)

15、fill_up_shape (Wires, WiresFilled, 'area', 1, 100)

16、opening_circle (WiresFilled, Balls, 15.5)

17、connection (Balls, SingleBalls)

18、select_shape (SingleBalls, IntermediateBalls, 'circularity', 'and', 0.85, 1.0)

19、sort_region (IntermediateBalls, FinalBalls, 'first_point', 'true', 'column')

20、dev_set_colored (12)

21、smallest_circle (FinalBalls, Row, Column, Radius)

22、disp_circle (WindowID, Row, Column, Radius)

23、disp_message (WindowID, 'D: ' + Diameter$'.4', 'image', Row - 2 * Radius, Column, 'white', 'false')


程序源码

* ball.hdev: Inspection of Ball Bonding(球形焊点的检测)
*定位特征
*窗口更新、关闭、打开
dev_update_window ('off')
dev_close_window ()

*读取显示图片(如果是彩色图片转换为灰度图片)
read_image (Bond, 'die/die_03')
get_image_size(Bond, Width, Height)
dev_open_window_fit_image(Bond, 0, 0, -1, -1, WindowID)
dev_display (Bond)

*在显示的图片上设置字体(字体)
set_display_font (WindowID, 14, 'mono', 'true', 'false')
disp_continue_message (WindowID, 'black', 'true')
*当碰到stop时,程序停止,按F5继续
stop () 

*二值化,图像转换成矩形(在某一个区域内进行操作)
threshold (Bond, Bright, 100, 255)
shape_trans (Bright, Die, 'rectangle2')

*设置区域颜色、轮廓宽度、边缘(margin)
dev_set_color ('green')
dev_set_line_width (3)
dev_set_draw ('margin')
dev_display (Die)
disp_continue_message (WindowID, 'black', 'true')
stop ()

*缩小范围,在矩形区域进行操作
reduce_domain (Bond, Die, DieGrey)
threshold (DieGrey, Wires, 0, 50)
fill_up_shape (Wires, WiresFilled, 'area', 1, 100)
dev_display (Bond)
dev_set_draw ('fill')
dev_set_color ('red')
dev_display (WiresFilled)
disp_continue_message (WindowID, 'black', 'true')
stop ()

*开运算,用一个半径15.5的圆放进填充区域
opening_circle (WiresFilled, Balls, 15.5)
dev_set_color ('green')
dev_display (Balls)
disp_continue_message (WindowID, 'black', 'true')
stop ()

*把整体打散
connection (Balls, SingleBalls)
*选中特征为圆,是否足够圆(去掉不要的部分)
select_shape (SingleBalls, IntermediateBalls, 'circularity', 'and', 0.85, 1.0)
*对区域进行按列排序
sort_region (IntermediateBalls, FinalBalls, 'first_point', 'true', 'column')
dev_display (Bond)
*12个颜色
dev_set_colored (12)
dev_display (FinalBalls)
disp_continue_message (WindowID, 'black', 'true')
stop ()

*最小的外接圆
smallest_circle (FinalBalls, Row, Column, Radius)
*当成数组里有多少个元素,变量赋值
NumBalls := |Radius|
Diameter := 2 * Radius
meanDiameter := mean(Diameter)
minDiameter := min(Diameter)
dev_display (Bond)
disp_circle (WindowID, Row, Column, Radius)
dev_set_color ('white')
disp_message (WindowID, 'D: ' + Diameter$'.4', 'image', Row - 2 * Radius, Column, 'white', 'false')
dev_update_window ('on')

1、dev_update_window ('off')

1.	dev_update_off()
2.	dev_update_on()
3.	// 实际是把这三个函数置为"off"或"on"
4.	// 在程序执行期间,控制程序计数器的更新
5.	dev_update_pc ('off') 
6.	// 在程序执行期间控制变量窗口的更新或关闭,则每当程序修改变量时,更改变量窗口(图标和控件变量)的内容
7.	dev_update_var ('off') 
8.	// 程序执行打开和关闭期间,图像对象是否在图形窗口中显示;在单步模式下,该规则无效,单个算子调用以后,对象总是显示在图形窗口上;在测量一系列算子的运行时间的时候,应该设置为OFF,以减少HDevelop中GUI更新的运行时间的影响
9.	dev_update_window ('off') 
10.	// dev_update_time:控制是否显示算子的执行时间
  • 如果只有被选中的对象需要显示在图形窗口中,这个选项应该设置为“关闭”。在这种情况下,对象应该由dev_display显示。

2、dev_close_window ()

  • 关闭活动的浮动图形窗口
  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

盾山狂热粉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值