VisionPro - 基础 - 00 模板匹配技术和在VP中的使用 - PMAlign - PatMax - (4)- 控制模板的匹配

前言:

针对PatMax 的高级应用和原理,在这一节继续进行说明:这一节主要考虑的是PatMax模板匹配的原理:如何控制模板的匹配。

本节先介绍了几个模板匹配的衡量标准,比如模板匹配分数,和模板的几种模板匹配的结果。


Score 分数:

For each instance of the trained pattern that PatMax finds in the run-time image, it computes a score value between 0.0 and 1.0. The score an instance receives indicates how closely it matches the trained pattern. A score of 1.0 indicates a perfect match; a score of 0.0 indicates that the pattern does not match at all.

When you specify the PatMax algorithm, PatMax scores instances on both the closeness of pattern fit (the degree to which the shape of the features in the run-time image conforms to the shape of the features in the trained pattern) and the presence of clutter (extraneous features). When you specify the PatQuick algorithm, PatMax scores instances on pattern fit only.

In considering the fit, PatMax considers the shape of the pattern. Differences in brightness or contrast (as long as the polarity is the same) are ignored. (You can specify that PatMax ignore polarity changes in addition to brightness and contrast changes.)

PatMax is somewhat tolerant of elastic stretching of the pattern. PatMax tends to return lower scores for patterns with missing or extraneous features. Figure 15 shows examples of patterns with elastic stretching and patterns with missing or extraneous features (called broken patterns).

Figure 15. Pattern variations

模板匹配的得分,在0 到 1 之间。得分衡量实时图像的特征和训练的模板的相似度。1 为完美匹配。 PatMax的算法逻辑,如第一篇博客有提到,包括两个匹配的方面。1 就是图形特征的自由度匹配。 2 杂乱的非关键特征特征。当使用PatQuick,只考虑模板的形态匹配也就是方面1的内容。在模板匹配的时候,不可考虑亮度、对比度的变化。

匹配的时候,如果图形只是发生了自由度的变换,拉伸,角度,都会被认为是一个模板特征,但是,如果有丢失或者增加的特征,那么匹配的分数会给的极低。

上图中,中间栏对被训练的模板的匹配度比较高,因为只有拉伸的变换。而右边栏的分数很低,因为有缺失或者增加。

1 Fit Error, Coverage, and Clutter 匹配的三种输出结果

Fit Error

The fit error is a measure of the variance between the shape of the trained pattern and the shape of the pattern instance found in the run-time image.

The fit error is computed by taking the square root of the sum of the weighted average distances between each boundary point in the pattern and the corresponding boundary point in the pattern instance in the run-time image. If the pattern instance in the run-time image is a perfect fit for the trained pattern, the fit error is 0.0.

You can use the fit error to assess the degree to which the shape of a pattern instance matches the shape of the trained pattern.

Coverage Score

The coverage score is a measure of the extent to which all parts of the trained pattern are also present in the run-time image.

The coverage score is computed by determining the proportion of the trained pattern that is found in the run-time image. If all of the trained pattern is also present in the run-time image, the coverage score is 1.0. Lower coverage scores indicate that less of the pattern is present.

You can use the coverage score to detect missing or occluded features.

Clutter Score

The clutter score is a measure of the extent to which the found object contains features that are not present in the trained pattern.

The clutter score is the proportion of extraneous features present in the found object relative to the number of features in the trained pattern. A clutter score of 0.0 indicates that the found instance contains no extraneous features. A clutter score of 1.0 indicates that for every feature in the trained pattern there is an additional extraneous feature in the found pattern instance. The clutter score can exceed 1.0.

Fit Error: 就是模型匹配的结果,如果是匹配,值为0.

Converage Score: 这个是用来衡量一个图片中,如果有多个特征匹配的时候,是否有特征缺失的得分。如果完全没有确实,所有的特征都匹配上了为1.

Clutter Score:是否有额外的其他特征。1 表示有其他特征。

上图,展示了一个Clutter的例子,在左侧巡逻队模板外,有一个长方形的额外的特征。


Contrast 对比度
 

In addition to the overall score, PatMax also returns the image contrast of each instance of the pattern it finds in a run-time image. The contrast is the average difference in grey-level values for all of the boundary points that PatMax matched between the trained pattern and the pattern instance in the run-time image.

Since PatMax computes the score for a pattern based on the shape of the pattern, the contrast value and score value are generally independent. You can use the contrast value to get additional information about the object.

You can specify a contrast threshold for PatMax searches. If you specify a contrast threshold, only pattern instances where the average difference in grey-level values for all of the boundary points exceeds the contrast threshold are considered by PatMax.

【案,除了模型匹配的形体的得分外。PatMax还支持度对比度的匹配。对比度的值来自于所有边界像素点的灰度值的均值差。而且,由于模板的形体特征的匹配计算得分其实是几何形体特征,这样,对比度可以作为一个独立的匹配特征作为模板匹配搜索的一个参考阈值。


Controlling PatMax Alignment 控制模板匹配

1 Degrees of Freedom 自由度:

When you perform a pattern alignment using PatMax, for each generalized degree of freedom (a degree of freedom other than x-translation or y-translation), you must specify either

  • That the degree of freedom is disabled, in which case you must specify a nominal value for that degree of freedom. PatMax will only find instances of the pattern that are close to the specified nominal value for that degree of freedom, and PatMax will not compute a value for that degree of freedom; it will report the nominal value that you specify for the degree of freedom.

    or

  • That the degree of freedom is enabled, in which case you must specify a zone that defines the permitted range of values for that degree of freedom. PatMax will find instances of the pattern that have values for the degree of freedom within the specified zone, and PatMax will compute and report a value for the degree of freedom.

【自由度的定义,在前面的章节我们有定义。在除了X轴,Y轴缩放以外的通用自由度里面。

-  即使某个自由度被Disable,我们任然需要象征性的赋予一个值。PatMax会会找到和这个自由度相近象征值。

-  如果某个自由度使能了,也就是我们模板匹配需要的。这时候,你需要定义一个范围zone,这个自由度的阈值范围。PatMax会会找到和这个阈值范围匹配的模板实例,并计算出实际测量出来的自由度值。

If, for example, you are using PatMax to perform translation-only alignment of fiducial marks, you might disable the rotation and scale degrees of freedom and specify nominal values of 0 degrees for rotation and 1.0 for scale.

However, if your application encounters run-time images where the fiducial marks are rotated or scaled very slightly, PatMax will find these instances, but the accuracy of the location information may be slightly reduced and the instance may receive a lower score. PatMax will not compute a value for scale or rotation; it will report the nominal value that you specify for the degree of freedom.

【案,这里举了一个例子, translation-only alignment of fiducial marks 应该是只通过基准标记进行匹配。这时候,其他的自由度比如旋转,缩放应该给一个默认(象征性)的值。OK,如此设定的将有如下的负面效果,就是你的匹配图像的基准标记如果有哪怕很小的转动,或者缩放,你的匹配得分都会嗝屁。】

With each additional degree of freedom that you enable, PatMax requires additional processing time to analyze an image. In addition, the larger a zone you specify within a degree of freedom, the more processing time is required. For more information on optimizing alignment speed, see the section Optimizing PatMax Performance.

Finally, PatMax might return some model instances that are slightly outside the zone you specify. For example, if you specify a scale between 0.95 and 1.05, PatMax might return results with scale values of 1.09 or 0.91. You can always check the result values and exclude results that are outside the specified zone.

Specifying a nominal value for a degree of freedom lets you find patterns with small variations in the degree of freedom at the highest possible speed, since the degree of freedom is not part of the computation.

在上图给出的例子中,上面一栏,为设定了一个基准标记,这里设定为角度为0度。下面一栏,设定了一个旋转角度的范围。我们看到在做模板匹配的时候,上栏的右侧,黑框用0度的角度去进行匹配验算,而下栏的右侧黑框则进行了一定角度旋转尝试,再匹配。由此,得到的匹配分数,显然有角度范围定义的匹配度高于固定0度的匹配度,也就是0.98 VS 0.80.

[案,给出的角度的设定范围越大,需要的匹配的执行时间越长。同时,有角度范围的匹配在算法设计的时候,匹配的角度结果【例如,Rotation的角度结果】也不一定就是在设定的角度范围之内,有可能要大于在这个角度的设定范围。


1.1 Image Confusion 图像匹配异议和匹配分值

【案,图像匹配异议,这里就是不确定的意思】

As you increase the number of degrees of freedom and as you enlarge the zone for an individual degree of freedom, you increase the number of potential matches in a run-time image

 在前面的一节,我们提到,通过增加匹配的自由度的范围虽然损失了一些执行时间,但是可以提高匹配的精度。但是,也不是完全都是这样,因为匹配的自由度的范围越大,那么适合匹配的模板图形的可能数量就越大,这样,在某一个可能很低的匹配得分,匹配就已经发生了,并产生了结果。

shows one effect of enabling a degree of freedom on the confusion of the image. With the scale degree of freedom disabled, only a single instance is found. With scale enabled, the top of the pattern is a fair match for a scaled instance of the entire pattern.

上图中,展示了这种匹配范围带来的可能匹配得分的降低。在上图的左图,我们设定的缩放的自由度为不考虑,这时候,进行匹配的时候,得分是0.98的比较高的分数。而同样的图片,如果我们设定的自由度的考虑缩放,由于有更多可能的潜在的匹配的图,造成的结果就是,可以出来0.72的匹配得分,当然,我看到给出的说法因子的设定值为0.81.

1.2 Effect of Non-Uniform Scale Degrees of Freedom

Enabling the non-uniform scale degrees of freedom in PatMax reduces the accuracy level to that of the PatQuick algorithm.

 1.2.1 Non-Uniform Scale的定义

The x- and y-scale degrees of freedom allow you to specify variations from training to run-time objects that are called non-uniform scale variations, and provide alternative ways of specifying variations in aspect ratio from trained patterns to runtime objects.

所谓Non-Uniform Scale,定义为单独的X缩放,或者Y缩放。这些缩放,我们做视觉的都知道,就是aspect ratio的一些定义。

As with all generalized degrees of freedom, non-uniform scale variation can be specified using either nominal or zone parameters. Whenever a non-uniform scale zone is enabled, PatMax accuracy is limited to the lower accuracy of the PatQuick algorithm. Using non-uniform scale nominal values other than the default 1.0 results in no loss of accuracy.

 1.2.2 Non-Uniform Scale 的局限性

 使用PatMax的时候要注意,缩放自由度的使能,会造成PatQuick(不包括shape的模板匹配)低匹配分数。所以,对于缩放自由度使能后,默认应该设定一个基准标记,这样才不会丢失精度

 If the aspect ratio of your objects truly varies, you may have no choice but to use a non-uniform scale zone and accept the lower accuracy. In some applications, however, aspect ratio does not vary from object to object, but is nevertheless different from the trained pattern. Do not use non-uniform scale zones to get PatMax to find the correct aspect ratio, because accuracy will be limited to the lower accuracy of the PatQuick algorithm. Instead use non-uniform scale nominal values, a calibrated coordinate space, or pattern coordinates to specify the fixed variation in aspect ratio from training to run-time.

 【案,这里是PatMax 8.2的一个小局限吧,如果要用Zone(也就是有范围的)缩放自由度,这必将降低匹配的精度。所以,不要用训练模板的方法来获取变化的缩放系数,尽量尝试其他的坐标标定的方法取代】


Expected Result Count and Accept Thresholds 模板匹配结果和阈值

小结,有了模板匹配的分值的计算方法,我们可以通过设定匹配分值的阈值来判断是否搜索到了正确的模板特征值。

When you search for a pattern using PatMax, you specify the number of instances you expect to be present in the run-time image and an accept threshold that specifies the minimum score value that an actual instance of the pattern is expected to receive.

PatMax returns information about all of the objects in the run-time image that receive scores above the accept threshold you specify up to the number of instances that you specify.

If there are multiple instances with similar scores, PatMax can return information about more instances than you specify. For example, if you specify an accept threshold of 0.50 and an expected result count of 2, and PatMax finds five instances with the following scores:

0.98
0.70
0.68
0.32
0.19

 下面是算子的官方解释:

PatMax will return information about the first three instances, even though you only requested two. PatMax does this because of the potential ambiguity between the two results with scores of 0.70 and 0.68.

Cognex can make the following recommendations for setting the accept threshold:

  • Specifying a low accept threshold forces the PMAlign tool to consider more potential matches while increasing the time required for the tool to execute. Specifying a high accept threshold allows the tool to eliminate non-matches and decreases the execution time, but at the risk of failure to locate an actual instance of the pattern.
  • The tool uses a coarse accept threshold of 0.66 to help refine the alignment process when considering potential matches. By default, any coarse search results with scores above (0.66 x accept threshold) will be further considered for a potential match. Lowering the default coarse accept threshold can allow the tool to include more potential matches based on their coarse features. This can be the best solution in images where you find lowering the accept threshold a fractional amount results in the tool finding patterns with high search scores. Instead of lowering the accept threshold, experiment with lowering the coarse accept threshold instead. Upon each successful execution of the tool, a coarse score is generated to indicate the lowest value that the coarse accept threshold can be set to and still allow the pattern to be found. You can experiment with the coarse accept threshold if the PMAlign tool fails to find good matches in your test images.

【案,这都是应用配置的说明,基本上意思就是你的阈值越低,出现匹配的概率越大。反之亦然。然后,系统默认的一个阈值为0.66. 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/1541520.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

二维光场分析

一、单色光波长的复振幅表示 实波函数 复波函数 复振幅 由于时间因子相同,可以用复振幅来描述 光强 1.1 球面波的复振幅(单色点光源发出的光波) 等相位面是同心球面,波矢处处与等相位面垂直,即 是 r = 1 处的振幅 发散球面波: 会聚球面波: <

SOMEIP_ETS_121: SD_Initial_Events_after_SubscribeEventgroup

测试目的&#xff1a; 验证DUT在接收到Tester的SubscribeEventgroup消息后&#xff0c;能够发送SubscribeEventgroupAck确认消息&#xff0c;并立即发送对应的初始化字段给订阅的事件组。 描述 本测试用例旨在确保DUT能够正确响应SubscribeEventgroup消息&#xff0c;通过发…

arthas -- xxljob本地调试

方案一&#xff1a;测试类 package cn.wanda.wic.content.job.xxljob;import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest;import javax.annotation.Resource;SpringBootTest public class ShopResourceMigrationJobTest {Reso…

探索人工智能绘制宇宙地图的实现

人工智能 (AI) 已成为了解世界的重要工具。现在&#xff0c;随着人们对太空探索的兴趣重新升温&#xff0c;人工智能也可能对其他世界产生同样的影响。 尽管经过了几十年的研究&#xff0c;科学家们对地球大气层以外的宇宙仍然知之甚少。绘制行星、恒星、星系及其在太空中的运…

CCRC-CDO首席数据官:未成年人首次上网年龄持续降低

近日&#xff0c;中国社会科学院新闻与传播研究所联合社会科学文献出版社发布了《青少年蓝皮书&#xff1a;中国未成年人互联网运用报告(2024)》&#xff0c;该报告对中国未成年人的互联网使用情况进行了全面的研究和专项汇报。 调查数据透露&#xff0c;未成年人接触网络的年…

OpenHarmony(鸿蒙南向开发)——标准系统方案之瑞芯微RK3568移植案例(上)

往期知识点记录&#xff1a; 鸿蒙&#xff08;HarmonyOS&#xff09;应用层开发&#xff08;北向&#xff09;知识点汇总 鸿蒙&#xff08;OpenHarmony&#xff09;南向开发保姆级知识点汇总~ OpenHarmony&#xff08;鸿蒙南向开发&#xff09;——轻量和小型系统三方库移植指南…

[python]从零开始的PySide安装配置教程

一、PySide是什么&#xff1f; PySide 是 Qt for Python 项目的一部分&#xff0c;它提供了与 PyQt 类似的功能&#xff0c;使开发者能够使用 Python 编程语言来构建基于 Qt 的图形用户界面 (GUI) 应用程序。PySide 是由 Qt 公司官方维护的&#xff0c;而 PyQt 则是由第三方开发…

化学分子结构检测系统源码分享

化学分子结构检测检测系统源码分享 [一条龙教学YOLOV8标注好的数据集一键训练_70全套改进创新点发刊_Web前端展示] 1.研究背景与意义 项目参考AAAI Association for the Advancement of Artificial Intelligence 项目来源AACV Association for the Advancement of Computer…

day-57 边积分最高的节点

思路 因为节点编号从0到n-1&#xff0c;所有可以创建一个数组用来记录每个节点的边积分&#xff0c;遍历edges数组&#xff0c;并且令ansarr[edges[i]]i&#xff0c;遍历结束后即可得到每个节点的边积分&#xff0c;再遍历ansarr数组&#xff0c;找到值最大的那个索引即为答案&…

硬盘格式化后能恢复数据吗?试试这四款工具吧!

数据丢失&#xff0c;这可能是每个电脑用户都曾遇到过的噩梦。今天&#xff0c;我就来给大家分享一下我使用过的四款数据恢复软件在实际操作中的表现&#xff0c;看看哪款软件能成为你数据恢复的得力助手。 一、福昕数据恢复 网址&#xff1a;https://www.pdf365.cn/foxit-re…

UI自动化测试框架:PO模式+数据驱动详解

1. PO 设计模式简介 什么是 PO 模式&#xff1f; PO&#xff08;PageObject&#xff09;设计模式将某个页面的所有元素对象定位和对元素对象的操作封装成一个 Page 类&#xff0c;并以页面为单位来写测试用例&#xff0c;实现页面对象和测试用例的分离。 PO 模式的设计思想与…

[数据结构与算法·C++版] 笔记 1.2 什么是数据结构

1.2 什么是数据结构 结构&#xff1a;实体 关系数据结构&#xff1a; 按照逻辑关系组织起来的一批数据&#xff0c;按一定的存储方法把它存储在计算机中在这些数据上定义了一个运算的集合 数据结构的逻辑组织 线性结构 线性表&#xff08;表&#xff0c;栈&#xff0c;队列&…

11.1 溪降技术:下方保护

目录 11.1 下方(底部)保护概述观看视频课程电子书&#xff1a;底部保护技术要点 11.1 下方(底部)保护 概述 一名峡谷探险者为他的队友提供底部保护 峡谷探险是一项团队运动&#xff0c;作为峡谷探险团队的一员意味着在下降过程中要相互帮助、协作&#xff0c;特别是要关心彼此的…

库函数模块创建

工程创建 创建这个工程模版&#xff0c;是为了我们后面免去我们后面创建工程模版的步骤 创建这个文件&#xff0c;这个文件是用来存放我们编译生成的一些中间文件&#xff0c;C&#xff0c;汇编&#xff0c;链接的一些列表清单&#xff0c;调试信息&#xff0c;以及需要我们下…

Linux命令--05----find 日志

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 find1.语法语法&#xff1a;find 目标目录(路径) <选项> 参数 2.示例3.find 结合 xargs4.案例.* 模糊匹配 绝对路径 find 在 Linux 命令中&#xff0c;fin…

【Python】探索 Graphene:Python 中的 GraphQL 框架

人们常说挣多挣少都要开心&#xff0c;这话我相信&#xff0c;但是请问挣少了怎么开心&#xff1f; 随着现代 Web 应用对数据交互需求的不断增长&#xff0c;GraphQL 作为一种数据查询和操作语言&#xff0c;越来越受到开发者的青睐。Graphene 是 Python 语言中实现 GraphQL 的…

Redis面试真题总结(三)

文章收录在网站&#xff1a;http://hardyfish.top/ 文章收录在网站&#xff1a;http://hardyfish.top/ 文章收录在网站&#xff1a;http://hardyfish.top/ 文章收录在网站&#xff1a;http://hardyfish.top/ 什么是缓存雪崩&#xff1f;该如何解决&#xff1f; 缓存雪崩是指…

Unity 高亮插件HighlightPlus介绍

主要是对官方文档进行了翻译(我做了一些补充和一些小的调整) 但是如果你只是想快速入门: Unity 高亮插件Highlight Plus快速入门-CSDN博客 注意:官方文档本身就落后实际,但对入门仍很有帮助,核心并没有较大改变,有的功能有差异,以实际为准.(目前我已校正了大部分差异,后续我…

appimage 软件创建桌面快捷图标

1、appimage 软件创建桌面快捷图标 1&#xff09;下载 AppImage 文件 首先&#xff0c;确保你已经下载了 AppImage 文件&#xff0c;并且该文件具有可执行权限。你可以通过以下命令为 AppImage 文件添加可执行权限&#xff1a; chmod x /path/to/your-app.AppImage2&#xff…

【复现】Grounding DINO使用记录

推理 问题 1. ModuleNotFoundError: No module named groundingdino 解决&#xff1a; 运行 python setup.py install 编译groundingdino库。或者直接引入环境变量&#xff1a; linux&#xff1a; export PYTHONPATH$PYTHONPATH:/data/groundingdino windows&#xff1…