基于blob分析的焊盘定位

焊盘定位

原图

在这里插入图片描述

代码

*这个示例程序演示了如何在图像中查找焊盘,
*以及如何使用fit_rectangle2_contour_xld来确定它们的位置、旋转和大小。
dev_update_window ('off')
read_image (Image, 'pads')
dev_close_window ()
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width * 2, Height * 2, 'black', WindowHandle)
dev_set_part (0, 0, Height - 1, Width - 1)
* blob分析,寻找焊盘位置
fast_threshold (Image, Region, 180, 255, 20)
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, ['area','anisometry'], 'and', [200,1], [1200,2])
* 构造一个用于亚像素级精确边缘检测的ROI。
fill_up (SelectedRegions, RegionFillUp)
shape_trans (RegionFillUp, RegionTrans, 'convex')
boundary (RegionTrans, RegionBorder, 'inner')
dilation_circle (RegionBorder, RegionDilation, 2.5)
union1 (RegionDilation, RegionUnion)
* 进行亚像素级的精确边缘检测。
reduce_domain (Image, RegionUnion, ImageReduced)
edges_sub_pix (ImageReduced, Edges, 'sobel_fast', 0.5, 20, 40)
* 筛选
select_shape_xld (Edges, SelectedContours, 'contlength', 'and', 10, 200)
* 合并相邻边缘碎片以获得每个焊盘的一个轮廓。。
union_adjacent_contours_xld (SelectedContours, UnionContours, 2, 1, 'attr_keep')
* 最小外接矩形
fit_rectangle2_contour_xld (UnionContours, 'tukey', -1, 0, 0, 3, 2, Row, Column, Phi, Length1, Length2, PointOrder)
gen_rectangle2_contour_xld (Rectangle, Row, Column, Phi, Length1, Length2)
*显示
dev_display (Image)
dev_set_colored (12)
dev_display (Rectangle)
dump_window (WindowHandle, 'png', '定位结果')

结果

在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值