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

news2024/9/22 2:52:19

前言:

针对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.coloradmin.cn/o/2153947.html

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

相关文章

计算机毕业设计 基于Python的美术馆预约系统的设计与实现 Python+Django+Vue 前后端分离 附源码 讲解 文档

🍊作者:计算机编程-吉哥 🍊简介:专业从事JavaWeb程序开发,微信小程序开发,定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事,生活就是快乐的。 🍊心愿:点…

pytorch实现RNN网络

目录 1.导包 2. 加载本地文本数据 3.构建循环神经网络层 4.初始化隐藏状态state 5.创建随机的数据,检测一下代码是否能正常运行 6. 构建一个完整的循环神经网络 7.模型训练 8.个人知识点理解 1.导包 import torch from torch import nn from torch.nn imp…

如何解决DataGrip的 Public Key Retrieval is not allowed错误

对于 DataGrip 出现 [08001] Public Key Retrieval is not allowed 错误,原因通常是 MySQL 的安全机制不允许客户端检索公钥。你可以通过以下步骤来解决这个问题: 解决步骤: 修改 DataGrip 中的连接设置: 打开 DataGrip。在左侧导…

CLion/Git版本控制

文章目录 文章介绍准备工具操作首次提交修改代码提交第二版 文章介绍 记录用clion和git做代码的版本控制 准备工具 CLion2024.2.0.1 git 操作 首次提交 该文件夹的打开方式选择clion 全部提交 成功提交后查看分支 修改代码提交第二版

hutool 解压缩读取源文件和压缩文件大小失败导致报错

前言 最近处理老项目中的问题,升级安全jar,发现hutool的jar在解压缩的时候报错了,实际上是很简单的防御zip炸弹攻击的手段,但是却因为hutool的工具包取文件大小有bug,造成了解压缩不能用,报错:…

山东潍坊戴尔存储服务器维修 md3800f raid恢复

山东戴尔存储故障维修 存储型号:DELL PowerVault md3800f 故障问题:存储除尘后通电开机,发现有物理硬盘没有插到位,用户带电拔插了多块物理盘,导致关连的磁盘阵列掉线,卷失败; 处理方式&#xf…

Python基于Django、大数据的北极星招聘数据可视化系统

博主介绍:✌程序员徐师兄、7年大厂程序员经历。全网粉丝12w、csdn博客专家、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ 🍅文末获取源码联系🍅 👇🏻 精彩专栏推荐订阅👇…

[JavaEE] TCP协议

目录 一、TCP协议段格式 二、TCP确保传输可靠的机制 2.1 确认应答 2.2 超时重传 2.3 连接管理 2.3.1 三次握手 2.3.2 四次挥手 2.4 滑动窗口 2.4.1 基础知识 2.4.2 两种丢包情况 2.4.2.1 数据报已经抵达,ACK丢包 2.4.2.2 数据包丢包 2.5 流量控制…

国标GB28181视频融合监控汇聚平台的方案实现及场景应用

Liveweb国标视频融合云平台基于端-边-云一体化架构,部署轻量简单、功能灵活多样,平台可支持多协议(GB28181/RTSP/Onvif/海康SDK/Ehome/大华SDK/RTMP推流等)、多类型设备接入(IPC/NVR/监控平台),在视频能力上&#xff0…

图解 | 消息认证码(MAC)到底解决了什么问题?还有什么问题是它解决不了的?

消息认证码(Message Authentication Code,MAC)是一种用于验证数据完整性和来源可信性(对消息进行认证)的技术。它通常由一个密钥和被保护的消息通过特定算法计算得出,接收方可以使用相同的密钥(…

C++类之set与get理解

在类中,我们尝尝将一些变量设置为private或者protect里面,而我们经常会遇到在主函数(main.cpp)使用到这些private变量,而往往我们会下意识地在主函数直接调用在private里面的变量,但现实比较残酷&#xff0…

20240921解决使用PotPlayer在WIN10电脑播放4K分辨率10bit的视频出现偏色的问题

20240921解决使用PotPlayer在WIN10电脑播放4K分辨率10bit的视频出现偏色的问题 2024/9/21 10:40 缘起:常见的问题,你下载视频的时候,4K分辨率的视频播放的时候出现偏色异常,但是1080p分辨率的正常呀! 偏色的识别&…

re题(32)BUUCTF-[MRCTF2020]hello_world_go

BUUCTF在线评测 (buuoj.cn) 查壳,无壳,64位elf文件 ida打开是go语言写的,shiftF12看字符串 ctrlF搜索字符串,得到flag 本题是go语言写的,可以用linux打开go语言文件,本题直接把flag放到了字符串表&#xf…

数据结构---二叉搜索树(二叉排序树)

什么是二叉排序树 二叉搜索树又是二叉排序树,当我们的是一颗空树或者具有以下性质时: 左子树不为空,左子树上的值都小于我们的根节点上的值。右子树不为空时,右子树上的值都大于我们的根节点上的值左右子树都是二叉搜索树&#…

我的AI工具箱Tauri版-VideoDuplication视频素材去重

本教程基于自研的AI工具箱Tauri版进行VideoDuplication视频素材去重。 该项目是基于自研的AI工具箱Tauri版的视频素材去重工具,用于高效地处理和去除重复视频内容。用户可以通过搜索关键词"去重"或通过路径导航到"Python音频技术/视频tools"模…

封装的例题

答案A 解析: 选项B说法也正确,但是不如A更有效 选项C 不管采用什么方法,文档是必须要写的 选项D 说法太绝对了,如果封装的内容不适合,开发者可能做软件开发反而难度系数加大

芯片开发(1)---BQ76905---底层参数配置

主要开发思路:AFE主要是采集、保护功能、均衡,所以要逐一去配置芯片的寄存器 采集、均衡功能主要是配置引脚 保护功能主要是参数寄存器配置,至于如何使用命令修改寄存器参数该系列芯片提供了子命令和直接命令两种方式 BQ76905的管脚配置 I、参数配置 …

ubuntu 执行定时任务crontab -e 无法输入的问题

界面显示 GNU nano 4.8 /tmp/crontab.l0A1HJ/crontab # Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined t…

全国职业院校技能大赛(大数据赛项)-平台搭建hive笔记

在大数据时代,数据量呈爆炸性增长,传统的数据处理工具已难以满足需求。Hive作为一个开源的数据仓库工具,能够处理大规模数据集,提供了强大的数据查询和分析能力,是大数据学习中的关键工具。在全国职业院校技能大赛&…

【图像检索】基于Gabor特征的图像检索,matlab实现

博主简介:matlab图像代码项目合作(扣扣:3249726188) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 本次案例是基于Gabor特征的图像检索,用matlab实现。 一、案例背景和算法介绍 这次博…