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

news2024/9/22 15:22:55

前言:

针对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

1.2.0 Uniform Scale 等比例缩放:

Uniform Scale是等比例缩放的意思,这个类似数学的相似形,比如相似三角形。相似所以是等比例的。

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.coloradmin.cn/o/2155351.html

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

相关文章

JAVA并发编程系列之Semaphore信号量剖析

腾讯T2面试,现场限时3分钟限最多20行代码,模拟地铁口安检进站。其中安检入口10个,当前排队人数是100个,每个人安检进站耗时5秒。开始吧! 候选人,心中万马奔腾!!!吐了一口82年老血&am…

re题(37)BUUCTF-[GWCTF 2019]xxor

BUUCTF在线评测 (buuoj.cn) 用ida打开文件,ctrle定位main函数 也可以用shiftF12查找字符串,找与我们解题有关的字符串 通过字符串定位到引用字符串的函数 进入main entry 但还不是我们要分析的代码 进入__libc_start_main中的main参数,是我们…

C++20 std::format

一、前言 1、传统 C 格式化的问题与挑战 可读性差:使用 C 中的 printf 和 scanf 家族函数进行格式化输出和输入时,它们的语法较为复杂,难以阅读。在较大的代码项目中,可读性差会导致维护困难。类型安全性差:printf 和…

IS-ISv4/6双栈

文章目录 IS-ISv4/6双栈实验要求配置 IS-ISv4/6双栈 实验要求 配置双栈 R1、2、3、4配置 IS-ISv4 和 IS-ISv6,配置IPv6多拓扑 上面为Level-1类型、中间为Level-1-2、下面是Level-2类型 还有就是说ATT位置1有一定要求连接L1/2连接L1或者L2类型路由器,至…

java23发布啦

2024年9月java23发布啦!!! JDK 23 提供了12 项增强功能,这些功能足以保证其自己的JDK 增强提案 - JEP ,其中包括 8 项预览功能和 1 项孵化器功能。它们涵盖了对 Java 语言、API、性能和 JDK 中包含的工具的改进。除了 Java 平台上…

KVM环境下制作ubuntu qcow2格式镜像

如果是Ubuntu KVM环境是VMware虚拟机,需要CPU开启虚拟化 1、配置镜像源 wget -O /etc/apt/sources.list https://www.qingtongqing.cc/ubuntu/sources.list2、安装kvm qemu-img libvirt kvm虚拟化所需环境组件 apt -y install qemu-kvm virt-manager libvirt-da…

安装黑群晖,并使用NAS公网助手实现DDNS动态域名解析

很多人都会安装安装一个黑群晖进行练手,黑群晖有很多玩法和NAS套件,而且黑群晖安装比较简单,没有复杂的步骤,这也是很多人玩黑裙的理由,这里教大家如何安装黑群晖,并且安装神卓互联NAS公网助手实现DDNS动态…

arthas -- xxljob本地调试

方案一:测试类 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…

C\C++内存管理详解

本次内容大纲: 1.C/C内存分布 大家看看下面的代码 int globalVar 1; static int staticGlobalVar 1; void Test() {static int staticVar 1;int localVar 1;int num1[10] { 1, 2, 3, 4 };char char2[] "abcd";char* pChar3 "abcd";int…

本地快速部署一个简洁美观的个人Halo博客网站并发布公网远程访问

文章目录 前言1. Docker部署Halo1.1 检查Docker版本如果未安装Docker可参考已安装Docker步骤:1.2 在Docker中部署Halo 2. Linux安装Cpolar2.1 打开服务器防火墙2.2 安装cpolar内网穿透 3. 配置Halo个人博客公网地址4. 固定Halo公网地址 前言 本文主要介绍如何在Cen…

【Python日记】好丝滑的贪吃蛇

文章目录 原文:https://blog.c12th.cn/archives/39.htmlPython 贪吃蛇(pygame)前言部分代码完整代码 原文:https://blog.c12th.cn/archives/39.html Python 贪吃蛇(pygame) 前言 源代码参考B站: BV1cs411T7wW 效果展示 部分代码 框架 # 初始化 pygam…

基于微信小程序校园订餐的设计与开发+ssm(lw+演示+源码+运行)

摘 要 人民生活水平的提高就会造成生活节奏越来越快,很多人吃饭都采用点外卖的方式。现在点外卖的平台已有很多,大多都需要安装它们的APP才可以使用,并且没有针对校园。如果一味的使用外卖平台不仅会造成商家成本的增加,还不利于…

django应用JWT(JSON Web Token)实战

文章目录 一、什么是JWT二、为什么使用JWT三、在django项目中如何应用JWT1、安装djangorestframework-simplejwt库:2、在settings.py中配置JWT认证:3、在urls.py中配置JWT的获取和刷新路由: 四、JWT如何使用1、调用生成JWT的接口获取JWT2、客…

C++:类型转换(static_cast、reinterpret_cast、const_cast、dynamic_cast)、RTTI

C:类型转换(static_cast、reinterpret_cast、const_cast、dynamic_cast)、RTTI 一、C语言类型转换二、C新增强制类型转换2.1 新增类型转换:static_cast2.2 新增类型转换: reinterpret_cast2.3 新增类型转换&#xff1a…

新手上路:在Windows CPU上安装Anaconda和PyCharm

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 一. 确认自己是CPU为什么选择CPU教程?GPU与CPU的区别如何判断自己是CPU 二. Anaconda 安装包 和 Pycharm 安装包步骤1:下载Anaconda步骤2&am…

【d46】【Java】【力扣】234.回文链表

思路 判断是否是回文,需要:一个指针指向头,一个指针指向尾,两个指针一边向中间靠拢,一边判断数值是否相同 对于单链表,不方便获得pre,如果将节点放进 数组/list ,数组/list可以直接…

2024年9月22日历史上的今天大事件早读

189年9月22日 (汉灵帝中平六年八月戊辰)大将军何进入宫,策划铲除宦官,事败被杀 1499年9月22日 瑞士独立。 1630年9月22日 明朝抗清将领袁崇焕被崇祯皇帝凌迟处死于北京 1776年9月22日 美国间谍黑尔未经审判即被处绞刑 1860年9…

buucft hashcat

使用文本编辑器打开时乱码 使用010editor打开发现时xml文档 拷贝到kali,使用binwalk查看,发现时xml文档,改后缀名为ppt。打开发现有密码 Accent OFFICE Password Recovery 64位-Office密码恢复软件 v20.09 免费版 - 下载吧 试试这个Accent O…

[云服务器14] 搭建属于你自己的Git服务器

Git是由Linux Torvalds开发的一个版本控制系统(VCS,Version Control System),而目前最大的Git仓库托管公司就是大名鼎鼎的GitHub啦! 而这次,我们主要讲在自己的服务器上,搭建一个GitLab驱动的Git服务器! [请CSDN审核…

大模型的威力,远不只是聊天框

自2022年底ChatGPT发布以来,我们真正看到了大模型的威力,也引发了技术圈种种畅想。有相当一部分观点认为,大模型是一种工业革命级的产物,相信更多的人会和笔者一样,认为大模型是一个操作系统级的产品,会彻底…