VisionPro - 基础 - 模板匹配技术-应用3 - SearchPMAlinePatMaxAlignment Guidelines

时间:2024-09-30 16:08:03

前言:

Image Training 是VP最常用的一种模板匹配方法了。必须掌握:这节详细说明。

本节内容:

Shape Training
Image Training 
All PatMax Training
Large Images
PatMax Alignment Guidelines
PatFlex Guidelines

Run-time Information Strings
Optimizing PatMax Performance
Preventing Degenerate Results
Common Image and Pattern Variations
PatMax Parameter and Result Summary


1 Large Images 图像大小限制 

The PMAlign tool cannot function on any portion of an image where any pixel has a coordinate value (along either the x-axis or y-axis) that exceeds 32767. This limitation includes the area of the image you use to train a pattern and the image itself, as well as any region of interest you might specify. If necessary, you can pass the input image to a One Image Tool with no image-processing operations. A One Image Tool can be configured to simply generate a smaller output image where no pixel has a coordinate value of 32767, and then this image can be used as the input image to the PMAlign tool.

 PMAlign,只能处理坐标系范围(X,Y),分别小于32767pixel的图片。

2 PatMax Alignment Guidelines PatMax进行模板匹配指南

This section provides an overview of the parameters you specify when you use PatMax to search for a model in a run-time image.

In general, you should keep the following basic guideline in mind: The more specific the information that you can provide about the objects in the run-time image, the faster PatMax will operate. Each of the following items increases the size of the run-time space and increases the amount of time PatMax requires to find objects:

  • Increased number of enabled degrees of freedom
  • Larger zones for enabled degrees of freedom
  • Decreased accept threshold

Constraining the overall size of the run-time space can also tend to reduce the likelihood that PatMax will encounter degenerate results

这节提供了一个利用PatMax的进行模板搜索的基本参数的简介。

【越多的信息提供给算子,算子匹配的速度越快。空间换时间,永恒的话题。信息的提供,占用的空间包括 1 增加*度 2 更大的阈值范围 3 更低的阈值

2.1 Degrees of Freedom

For each of the possible degrees of freedom other than location you must either specify a nominal value, or a range of acceptable values. PatMax only searches within the combination of nominal and ranges that you specify.

In general, you should enable a degree of freedom and specify a zone if you expect patterns to vary in the degree of freedom or if you need to measure the degree of freedom.

 *度的设定,包括两个方面: 1 一个通用的值 2 一个可接受的范围值。 【案,其实就是一个中心值,和这个中心值的左右摇摆值】

2.2 Accept Threshold

The higher an accept threshold you specify, the faster PatMax will be able to perform an alignment. You should establish the accept threshold for your application by running a series of test alignments. Select an accept threshold that is slightly below the lowest score that an actual instance of the pattern receives.

A good starting point for the accept threshold is 0.5.

 更高的阈值设定,更快的算子将被执行。通常如果实际值和设定的阈值要进行匹配的时候,通过在运用的过程中,逐步完善阈值是一个最基本的模型匹配方法。VP的办法就是从0.5开始,然后不断地进行实验性的匹配,直到找到这个阈值。

2.3 Number to Find

You should specify the number of results that you expect the run-time image to contain. Because of PatMax's ability to find transformed versions of the trained pattern, run-time images may contain many more instances of a pattern than you might expect.

For most alignment applications, you should specify 1.

 算子会返回多个匹配的实例结果,sometimes,所以,设定返回的实例个数 为1 ,一般会帮助你拿到最配配对的样本图像。

2.4  Elasticity 弹性设定的理解        

Unless you expect pattern variations that cannot be described using a linear transformation, you should specify a value of 0.0 for elasticity.

If you experience alignment failures or unstable score results, you can begin experimenting with low elasticity values. In general, you should specify the lowest elasticity value that provides stable and consistent alignment results.

If you are expecting significant nonlinear pattern deformation, you should use the PatFlex algorithm.

 【案,模型匹配的模式中,线性匹配和非线性匹配,应用的分别是PatMax和PatFlex。对应线性匹配,避免匹配失败或者不稳定的匹配得分的最好的办法,就是设定最低的(阈值参数的)弹性值。

2.5 Scoring Clutter

If objects will appear on a variety of backgrounds, you should specify that PatMax ignore clutter when scoring objects.

If your application is an alignment application in which the background does not change, you should specify that PatMax consider clutter when scoring objects.

If you are using shape training because of extraneous features in your images, you should probably ignore clutter.

 【背景和纹理,如果有复杂的背景,这时候需要忽略杂乱参数(Clutter)对匹配分数的影响。反之,如果背景是固定没有变化,那么在评估匹配分数时候,应该加入杂乱参数。注意。如果匹配不是通过图像匹配,而是我们上一节提到的图形匹配,这个Clutter也应该是不要考虑的。

2.6 Extreme Scale Changes

PatMax can find patterns at a wide range of scale changes between the trained model and the run-time images. Increasing scale changes in the run-time image can affect PatMax performance and accuracy. You should keep in mind the following points about the effect of scale changes on PatMax:

  • The presence or absence of scale change itself has no effect on PatMax speed or accuracy.
  • The effect of increasing scale change is extremely image-dependent.
  • If you are searching for extremely small, simple patterns, train a larger pattern, preferably using a shape description.

As the size of the scale change between the trained pattern and the run-time pattern instance becomes very large, several factors come into play. These factors are different depending on whether your application uses patterns trained from acquired images or patterns trained from shape descriptions.

Note: All of the numbers discussed in this section are approximate. The specific performance of PatMax and the effect of specific scale changes is dependent on the content of the images used for pattern training and pattern location. You should conduct your own tests using a range of images to determine the best PatMax parameter settings for your application.

 【Scale的*度模式,由于算子有广泛的适应性,所以,需要很小心的定义匹配的参数。否则,返回的匹配实例会变得非常的巨大。建议就是对一些小的,简单的匹配图,最后用Shape 的模式,而不是图像的模式】

2.7 Patterns Trained From Acquired Images

As the size of scale change between the trained pattern and the run-time pattern increases, PatMax's performance can begin to degrade. In general, scale changes below 10% to 20% have no effect on PatMax's ability to discriminate patterns within a run-time image, and no effect on PatMax's ability to locate patterns with ultrahigh precision (better than 0.10 pixels).

As scale change increases above 10% to 20%, some applications will experience a reduction in accuracy levels.

At extremely large scale changes (greater than a factor of 2), some applications will experience problems discriminating patterns in run-time image.

PatMax is more likely to be able to successfully handle large scale changes when the overall shape of the trained pattern does not change at different granularities. 

【缩放的大小如果增加,会导致匹配的表现比较低下。总体来说,缩放的改变最好在10% 到 20%,就不会影响PatMax的辨别模板的能力。如果保证在0.1个像素内,那么也不会影响匹配模版的高精度定位。如果大于 10% 到 20%,警徽降低精度水平。

定义比较大的缩放改变,我们可以定义为(因子设定为1或2)。值得注意的是,缩放的成功匹配和物体的外形的粒度的设定强相关。

【理解外形的粒度值的影响,我们看下面的图,外形为齿轮状的物体,在粒度为1时,和粒度为10的时候,会有极大的不同。这时候,如果使用scale(缩放)*度,但是,期待一个准的结果就比较难了。

相反,

 

本身不收粒度设定印象的图,就会好太大。如上图,圆心本身就没有粒度的影响。

Note: If the run-time pattern is less than about one third the size of the trained pattern, the coverage score it receives will be reduced. This reduced coverage score, in turn, lowers the overall score received by the pattern, even though the shape of the pattern may be a good match with the trained pattern.


3 PatFlex Guidelines

You should only use the PatFlex algorithm under the following conditions:

  • You expect significant nonlinear deformation of the trained pattern in your run-time images.
  • You wish to produce an undeformed version of the run-time image.

The guidelines in this section can help you use the PatFlex algorithm effectively.

【案,PatMax PatFlex都行模板搜索的模式,其中PatFlex最适合的是扭曲的变换】

3.1 Use Appropriate Image Content

PatFlex works best when used to locate patterns with the following characteristics:

  • A range of feature sizes
  • A variety of feature shapes and orientations

You should avoid using PatFlex with patterns that are dominated by regular arrangements of straight lines.

 【PatFlex 在一下特征的匹配模版图像中有更好的效果,1 有一定范围的特征的大小改变 2 多变的形状和方向。同时,他也特别不适合处理有规律的直线的多组直线的情况】

3.2 Limit the Number of Control Points

Increasing the number of control points tends to increase the amount of time required to refine a PatFlex result. In most cases, PatFlex will return accurate results if you specify six control points in both the X- and Y-direction.

 【控制点位的增加将增加时间的花费。一般来说,有6个控制点位(包括X,Y的方向)都能活动比较准的结果。

3.3 Limit Degrees of Freedom and Deformation Rate

As is the case with the standard PatMax and PatQuick algorithms, increasing the number of enabled degrees of freedom or the zone size for any enabled degree of freedom increases the amount of time required for the search. The maximum deformation rate (specified at run time) has a similar effect on performance; the larger the maximum deformation rate, the longer the search may take.

Specifying a larger expected deformation rate (at training time) increase training time but has only a small effect on search time.

 【案,设定一个扭曲度的范围,可以增加匹配搜索的效率】