HALCON从入门到入门-线路板方块提取

测试效果

算法步骤详解

1.读取图片

read_image (Image, 'die_pads')

2.二值化并根据面积和各向异性筛选区域

在几何学和图像处理领域,"anisometry"通常用来描述物体或形状在不同方向上的尺寸差异,即形状的各向异性。这种差异可以通过计算长轴(Ra)与短轴(Rb)的比率来量化,即Anisometry = Ra / Rb。

fast_threshold (Image, Region, 180, 255, 20)

connection (Region, ConnectedRegions)

select_shape (ConnectedRegions, SelectedRegions, ['area','anisometry'], 'and', [200,1], [1200,2])

3.获取区域边界并膨胀

fill_up (SelectedRegions, RegionFillUp)

shape_trans (RegionFillUp, RegionTrans, 'convex')

boundary (RegionTrans, RegionBorder, 'inner')

dilation_circle (RegionBorder, RegionDilation, 2.5)

union1 (RegionDilation, RegionUnion)

4.基于ROI实现边界提取

reduce_domain (Image, RegionUnion, ImageReduced)

edges_sub_pix (ImageReduced, Edges, 'sobel_fast', 0.5, 20, 40)

5.筛选出合适的轮廓线,并拟合成矩形

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)

测试代码

* This example program shows how to find pads in an image and how to
* determine their position, rotation, and size robustly and accurately using
* fit_rectangle2_contour_xld.
dev_update_pc ('off')
dev_update_window ('off')
dev_update_var ('off')
read_image (Image, 'die_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)
* Find the pads in the image using blob analysis.
fast_threshold (Image, Region, 180, 255, 20)
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, ['area','anisometry'], 'and', [200,1], [1200,2])
* Construct a ROI for subpixel-accurate edge detection.
fill_up (SelectedRegions, RegionFillUp)
shape_trans (RegionFillUp, RegionTrans, 'convex')
boundary (RegionTrans, RegionBorder, 'inner')
dilation_circle (RegionBorder, RegionDilation, 2.5)
union1 (RegionDilation, RegionUnion)
* Perform the subpixel-accurate edge detection.
reduce_domain (Image, RegionUnion, ImageReduced)
edges_sub_pix (ImageReduced, Edges, 'sobel_fast', 0.5, 20, 40)
* Select the edge fragments that belong to the pads.
select_shape_xld (Edges, SelectedContours, 'contlength', 'and', 10, 200)
* Merge adjacent edge fragments to obtain one contour per pad.
union_adjacent_contours_xld (SelectedContours, UnionContours, 2, 1, 'attr_keep')
* Fit rectangles robustly to the pads' edges.
fit_rectangle2_contour_xld (UnionContours, 'tukey', -1, 0, 0, 3, 2, Row, Column, Phi, Length1, Length2, PointOrder)
* Generate rectangles from the fitting result for visualization purposes.
gen_rectangle2_contour_xld (Rectangle, Row, Column, Phi, Length1, Length2)
dev_display (Image)
dev_set_colored (12)
dev_display (Rectangle)

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
"Halcon入门到精通.pdf" 是一本关于Halcon 软件的学习资料,在网络上我们可以通过网盘来分享和下载这本书。 网盘是一种在线存储和分享文件的工具。通过网盘,用户可以将文件上传到服务器上,然后生成一个文件链接。其他用户则可以通过该链接下载文件。与传统的文件传输方式相比,网盘具有上传下载快速、方便、安全的特点。 对于"Halcon入门到精通.pdf"这样的学习资料,使用网盘来分享是非常合适的。首先,这样可以让更多的人获得学习机会,无论是学习软件的初学者还是想进一步提高的专业人士。其次,通过网盘分享,可以避免传统的文件复制和邮件发送过程中的版本混淆和文件丢失问题。最后,网络上的网盘资源丰富,用户可以通过搜索引擎或文件分享网站找到自己所需的学习资料。 使用网盘下载"Halcon入门到精通.pdf"时,建议大家首先确保所使用的网盘链接来源可靠。在下载之前最好对文件进行一定的检查,以确保文件的完整性和安全性。此外,强烈建议大家在下载和使用学习资料的过程中遵守相关的法律和规定,不要进行非法的复制和传播行为。 总而言之,网盘是一个方便快捷的文件分享和下载工具。对于"Halcon入门到精通.pdf"这样的学习资料,使用网盘来分享和获取是非常适合的。希望这份回答能对您有所帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

黄晓魚

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

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

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

打赏作者

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

抵扣说明:

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

余额充值