在PCB图像上寻找Pads区域(find_pads.hdev)

1.1应用示例思路

(1) 利用Blob分析(一般步骤:图像阈值分割、获取连通区域、计算Blob的相关几何特征),获取ROI区域。

(2) 剪切出来ROI区域中的图像,并对图像进行边缘提取。

(3) 拟合矩形轮廓,并生成矩形XLD轮廓,来完成对PCB图像上Pads区域的定位。

1.2应用实例代码

*读取图像
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)
*根据面积('area')和区域的长轴和短轴的比值('anisometry')的特征筛选区域
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.
*剪切出来ROI区域中的图像
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.
*将UnionContours轮廓拟合成为一个仿射矩形轮廓
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.
*创建具有任意方向的矩形XLD轮廓
gen_rectangle2_contour_xld (Rectangle, Row, Column, Phi, Length1, Length2)
*显示图像
dev_display (Image)
*设置显示对象的颜色数目
dev_set_colored (12)
*显示pads区域
dev_display (Rectangle)

1.3结果展示

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Hi~ 可私信我了解后再进行下载~ 1.基于halcon算法平台; 2.提供深度图源文件以及解压密码; 3.代码预览: */********************************* * @文档名称: 基于点云的平面拟合。 * @作者: hugo * @版本: 1.1 * @日期: 2021-6-16 * @描述: 该方法支持点云平面拟合以及深度图平面拟合。 **********************************/* read_image (imageReal, './replay_38893_2021-6-7.tif') xResolution:=0.06 yResolution:=0.06 zResolution:=0.001 ScaleFactor:=[xResolution,yResolution,zResolution] rateLowRemove:=0.1 rateHighRemove:=0.1 dev_get_window (WindowHandle) *采样区域1 create_drawing_object_rectangle2 (300, 120, rad(90), 30, 20, DrawID) set_drawing_object_params (DrawID, 'color', 'red') set_drawing_object_params (DrawID, 'line_width', 1) attach_drawing_object_to_window (WindowHandle, DrawID) ......... TransPose := [0,0,d,0,0,0,0] rigid_trans_object_model_3d (SampledObjectModel3D1, TransPose, _SampledObjectModel3D1) rigid_trans_object_model_3d (ObjectModelPlane1, TransPose, _ObjectModelPlane1) create_pose (0, 0, Mean/2, 180, 0, 0, 'Rp+T', 'gba', 'point', Pose1) *visualize_object_model_3d (WindowHandle, [_ObjectModelPlane1,_SampledObjectModel3D1,SampledObjectModel3D2], [], [Pose1], [], ['intensity','lut','lut'], ['&amplitude','sqrt','sqrt'], '', 'Edited by AmazingRobot+ ' , PoseOut) visParamName := ['intensity_1','color_0','color_2','alpha_0'] visParamValue := ['coord_z','red','yellow',0.5] visualize_object_model_3d (WindowHandle, [_SampledObjectModel3D1,SampledObjectModel3D2,_ObjectModelPlane1], [], [], visParamName, visParamValue, 'Edited by AmazingRobot+', [], '', PoseOut) stop () 谢谢您的信任~
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值