halcon例程解析:检查相同药片——check_blister
原文介绍:
This example demonstrates an application from the pharmaceutical industry. The task is to check the content of automatically filled blisters. The first image (reference) is used to locate the chambers within a blister shape as a reference model, which is then used to realign the subsequent images along to this reference shape. Using blob analysis the content of each chamber is segmented and finally classified by a few shape features.
这个例子演示了一个制药行业的应用程序。任务是检查自动填充的水泡的内容。第一幅图像(参考)用于定位气泡形状内的腔室作为参考模型,然后使用该参考模型重新排列随后的图像以达到该参考形状。采用斑点分析法对每个腔体的内容进行分割,最后通过一些形状特征对其进行分类。
1. 效果展示
利用一个标准图像做模板,检测药片的有无、错误
模板图与检测图


结果

2. 思路分析
- 利用参考图建立每个药片的位置模型
- 分割出前景区域
- 计算其旋转,刚性映射变换摆正
- 确定目标区域,并计算得到其中心与偏转角,用于对检测图像进行刚性矫正
- 矫正检测图像,确定检测区域
- 分割出前景区域
- 计算其旋转、中心
- 利用参考图的中心与偏角对检测区域进行刚性变换
- 利用模板区域分割出检测区域
- 对检测区域进行定性分析,分类
2.1 利用参考图建立每个药片的位置模型
* 取第一个通道数据
access_channel (ImageOrig, Image1, 1)
* 进行阈值分割,得到前景区域
threshold (Image1, Region, 90, 255)
shape_trans (Region, Blister, 'convex')
* 计算偏角
orientation_region (Blister, Phi)
* 计算中心与面积
area_center (Blister, Area1, Row, Column)
* 生成刚性仿射变换矩阵
vector_angle_to_rigid (Row, Column, Phi, Row, Column, 0, HomMat2D)
* 仿射变换,摆正图像
affine_trans_image (ImageOrig, Image2, HomMat2D, 'constant', 'false')
* 生成药片区域,这个数值是自己判断的
gen_empty_obj (Chambers)
for I := 0 to 4 by 1
Row := 88 + I * 70
for J := 0 t

本文详细解析了一段制药行业应用案例,通过Halcon算法实现药片位置检测、矫正与分类,展示了从参考图到结果分析的完整流程。
最低0.47元/天 解锁文章
725

被折叠的 条评论
为什么被折叠?



