自学内容网 自学内容网

VisionPro - 基础 - 模板匹配技术-应用2 - Search\PMAline\PatMax\Image Training 的使用和模型训练概论

前言:

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 training image

For image training PatMax uses all of the information in the pattern training image you supply. You should avoid including features in the training image that will not be present in the run-time image.

In order to train a pattern from a pattern training image, the image must contain distinguishable features. For best results, you should observe the following guidelines when selecting a training image:

  • The pattern should include both coarse and fine features.
  • The pattern should include information that will let PatMax distinguish instances that vary in all enabled degrees of freedom. Table 3 shows examples of patterns that might lead to degenerate results (as described in the section Degenerate Results.

 【通过图像来进行匹配,其实,在业界叫做非模板匹配。当然匹配的前提是,你需要有显著的特征。

  • 图像模板需包括粗略和精细的特征
  • 图像模板包括PatMax能够区别的自由度变量实例。

 【案,上表中,我们看到,对应缩放,封闭的图像模板比非封闭的模板有更明确的匹配特征。而对应旋转,则非对称的图像比对称的图像有更显著的匹配特性。】

2 Training Image Coordinate System and Calibration

If the training and run-time images have different coordinate systems or calibrations, then identical patterns in the run-time images will be found at different scale or angle than the trained pattern.

For example, if the same optical and mechanical configurations are used to acquire training-time and run-time images, but the training-time image selected coordinate space units are one half the size of the run-time image selected coordinate space units, the pattern in the run-time image will be found at a scale of 0.50.

You should make sure that the same calibration has been computed for both pattern training and run-time images. If you have not calibrated the pattern training and run-time images, then you should make sure that the optical and mechanical configurations used to acquire the images are the same.

 如果一个实施的图像,有两个坐标系或者标定支持,那么,和训练的模板比,同一张实时的被测图像,会有不同的缩放、或者角度的误差。【这是必然的,官方解释这里讲的显得有点多余】比如,在训练的图像坐标系,某个坐标轴的单位是在实测的坐标系的坐标单位的一半,那么模板匹配的结果也许会发现,scale的结果变成了0.5。

所以,要保证拍摄的模板训练和运行的实时图片的标定是一致的。或者,至少保证不同坐标系下,计算的单位为一致。

3 Which Features Are Trained 我们训练了哪些特征

PatMax considers all of the features contained within the supplied training region, but it may also consider some features from outside the training region. This happens under the following conditions:

  • If the pattern training window is close to the edge of the image, features that are closer to the edge of the image than the coarse granularity limit may not be detected. However, if the pattern training window is not close to the edge of the image then it is guaranteed that every feature inside the window is detected, regardless of the coarse granularity setting.
  • PatMax can detect features that are outside of the training region if those features are within the coarse granularity limit of the edge of the pattern training window and if they are not within the coarse granularity limit of the edge of the image.

 PatMax 被认为是在提供的训练区域进行特征的匹配,但是,也不尽然,他同时考虑在训练区域外的一些特征。尤其:

  • 如果模板训练的区域接近图像的边缘。特征和图像的边缘比较接近,接近值甚至小于粗糙度粒度的定义,这个特征会被忽略。反正,所有的边缘特征,都会确保在检测窗口里面被检测到,而不论你的粗糙度的粒度如何定义。
  • PatMax将检测在训练区域外的特性。只要这个特性符合粗糙粒度的阈值线,同时这个边缘不靠近图像的边缘。

图示1:

  • 【案,这里粗模板粒度边界的定义,是一个绿色的框,这点要注意理解】

图示2: 

 4 值得注意的地方:

上图,依据图像匹配模版的逻辑,在训练的区域外,两侧的两个软盘的特性有可能在检测的时候被考虑进去。

由此,

In general, you should observe the following basic guidelines:

  • Do not train a pattern that has features that are close to and just outside the training window; these features may get trained in as a part of the pattern.
    1. Do not train a pattern with features that are close to and just inside the training window if the window is close to the edge of the training image; these features may not get included in the trained pattern.
    2. Always examine the graphic display of the feature boundary points trained as part of a pattern; verify that all the features you expected to be trained are trained and that no extraneous features from outside the training image window are trained.

 我们在使用这个算子的时候,需要注意:1 主要就是训练的窗口的边界的条件。2 要检测图形串口显示特性边界的点的情况。确保所有的被训练的特征都是你期望被训练的特征,而没有其他多余的特征。


2 All PatMax Training (PatMax 模型训练概论)

2.1 Pattern Granularity 模板粒度:

For most applications, PatMax does a good job selecting the coarse and fine pattern granularity limits. If you want to override PatMax's granularity limits, you should do so by evaluating the trained features.

Keep in mind that PatMax's strategy in choosing granularity limits is to choose the largest coarse granularity that detects features that can be reliably used to quickly locate the pattern and to choose the smallest fine granularity setting which will reliably and precisely locate the pattern.

The following are examples of when you might decide to override PatMax's settings:

  • If the coarse granularity trained feature display is including features that appear not to represent actual feature boundaries, you can try increasing the coarse pattern granularity to exclude the redundant small features. This might increase the alignment speed.
  • If the fine granularity trained feature display is including features that are not actually part of the pattern, such as surface texture, you could try increasing the fine pattern granularity to exclude the extraneous small features. This might improve reliability.
  • If the fine granularity trained feature display does not include fine features that are part of the pattern, such as fine teeth on a gearwheel, you could try decreasing the fine pattern granularity to include the small pattern features. This might increase accuracy.

You should not attempt to override PatMax's granularity settings without carefully examining the trained feature display. In general, you should choose the granularity that produce trained features that match the features of interest in the image.

Note: When using the PatFlex algorithm, the default granularities are generally smaller due to the need for more detail. If you set your own granularities they will also be generally smaller than those you would set for other algorithms.

【在大多数应用中,PatMax 会选择好粗,细的模板粒度边界。但,如果你想自己定义一个粒度的边界,需要评估以下的被训练的特征】

首先,要知道的原则。PatMax的策略是,选择粗的粒度用以快速的找到特征。而用细的粒度,来实现稳定和准确的定位。

1 通过粗粒度的特征显示,如果特征的表现没有反应实际的特征边界的情况,你需要增加粗模板的粒度来减少过剩的小特征。

2 如果细粒度的特征显示,没有包括实际的特征模板值,比如表面的纹理,你需要增加细粒度去减少无关的小特征。这会增加稳定性

3 如果细粒度的特征训练显示没有包括特征的细节特征,比如齿轮的齿牙,需要减小细模板粒度,从而增加对小特征的识别精确度。

2.2 Granularity Considerations with Shape Training

形态训练下的粒度考量。

As discussed in the section Computed Granularity, if you are using shape training and your shapes are much larger or smaller than the image features they describe, you may need to adjust the granularity limits manually to preserve meaningful features from the pattern.

Note: If you are using the PatFlex algorithm with shape-trained models, you will almost certainly need to set the granularity limits manually. In almost all cases, the granularity limits will need to be reduced from the automatically selected limits. Carefully review the display of trained features to make sure that reasonable features are being trained.

【 粒度的设定,在Shape training中,在如下情况需要要手搓:就是你的shapes(形态)远远大于图像的特征或者远远小于图像的特征的时候。】、

在PatFlex算子应用的时候,也需要这么考虑】

2.3 High Sensitivity Mode

PatMax can be run in standard mode or high sensitivity mode. Check your images for contrast and noise. Good quality images should be run in standard mode but if your images have poor contrast or are noisy, you may get better results using high sensitivity mode. Keep in mind however, high sensitivity mode generally requires more execution time than standard mode.

When you use high sensitivity mode you can also set the sensitivity parameter which allows you to specify your image quality. The sensitivity parameter is a number in the range 1.0 through 10.0 where lower numbers specify better quality images and higher numbers specify poor quality images. The default is 2.0. You may need to experiment with this parameter range to see which setting produces the best results for your images. See the discussion in the section High Sensitivity Mode.

PatMax有两种模式,1 标准模式 2 高敏模式

在不同的对比度和噪声下,选取不同的模式。好的图像质量,只需要运行在标准模式下。但是如果,图像对比度糟糕,而且有很多噪声,那么高敏模式是选择。

在选择高敏模式的时候,选择合适的敏感阈值参数。越低的参数越适合图像质量更好的图片。

2.4 Polarity 极性

By default, PatMax will only find matches where the trained pattern polarity and the run-time image pattern polarity are the same. You can specify that PatMax ignore the polarity of patterns in the run-time image. If you specify that PatMax ignore pattern polarity in the run-time image, you will increase the number of potential matches, which can increase image confusion. Also, ignoring pattern polarity reduces the search speed.

Note: You can change the value of this parameter at training time or run time with almost no execution time penalty, although the effect of changing the value can affect search speed.

The default for trained patterns specifies the darker side of a pattern boundary is negative and the lighter side of the boundary is positive. For example, see Figure 35

【图像识别中,极性这里指的是图像特征的灰度表述是正常的,还是反白的。比如一个黑的零件,可以反白(通过光照)打成白色,这就是极性的变换。算法默认采取训练模型的极性以提高匹配的准确性和速度。】

【默认的极性的定义,黑色为负极性,白色为正极性】

Enlarged portion of a trained pattern showing default polarity。上图的正号+为正极性区域,-号为负极性区域。

2.5 Repeating Patterns 重复模板

The PMAlign tool supports a boolean value that you can enable to indicate the pattern you want to train contains elements that repeat.

软件支持训练包括重复元素的模板。

2.6 Auto Edge Threshold 自动边界阈值

The PMAlign tool uses a default edge threshold value to detect the edges within the patterns you are trying to train and locate in your images. In patterns where the contrast between pattern features can be low, the PMAlign tool can fail to train or locate them as it executes. If necessary you can disable the default value and specify your own minimum grey value between edges.

 算法用默认的边界的阈值来训练和定位图像。当然,在模型对比度不明显的图像中,你可以自己设定边界的阈值。

2.7 Pattern Origin 原始模板

As described in the section Generalized Pattern Origin, PatMax lets you specify either a simple pattern origin point or a generalized pattern origin. This section provides guidelines for both origin forms.

在通用原始模板章节。算法定义了一个简单的原始点或者衣蛾泛化的元素模板。这里做一些更详细的说明:

2.7.1  Simple Pattern Origin 简单的模板原点(坐标)

PatMax returns the position (X-translation and Y-translation) of a found instance of the pattern in a run-time image as the location of the pattern origin in the run-time image's selected space.

When you specify the pattern origin location, keep in mind that if you enable any generalized degree of freedom, instances of the pattern might be reported at a shifted location.

Figure 36. Rotation causes apparent translation of pattern origin

【 算法返回定义的特征实例的位置信息(包括X,Y的变换坐标),在实时图像中,定位为运行图像的图像坐标系的模板原点。当你定义一个模板的原始坐标原点位置,记住,你使能了任何一个泛化的自由度,一个模板的实例将反馈了一个变换位置(也就是自由度的单一变换,带来位置的变换)。】

上图 shows an example where the transformation between the two patterns is rotation only, but because the an origin at the corner of the pattern training region is used, a translation is reported in addition to the rotation.

 上图,一个单一的自由度(旋转)自由度的变换,不仅仅只是带来了角度的变换。由于模板坐标的原点在图像左上角,经过旋转变换后,我们可以看到图像坐标的原点的X,Y的坐标位置,在变化后的图像坐标系中,发生了变化。在下图中,

由于一开始,模板的中心原点坐标在图像模板的中心,这样他的中心坐标在选择后的坐标模板中心,就不好发生改变了,因为单一的旋转自由度不会改变他的位置。

In general, you should either

  • Set the origin to correspond to a point of interest within the trained pattern.
  • Set the origin to be at the center of the trained pattern.

Note: If you are using the PatFlex algorithm, you should make sure to specify an origin that lies within the pattern; the run-time location of an origin outside of the pattern in a deformed image can be very inaccurate.

总的来说,1 你应该把相关的坐标原点设定在你选择的训练的模板里面 2 把相关坐标原点设在训练模板的中心。

2.7.2 Generalized Pattern Origin 泛化模板中心(坐标)

You specify a generalized pattern origin by supplying a transformation object at training time. PatMax applies this transformation to the training pattern before attempting to locate the pattern in a run-time image, and it returns results relative to the transformed training pattern.

In general, you supply a generalized pattern origin to compensate for known scale or rotation of the training pattern. For more information on using a generalized pattern origin, see the section Generalized Pattern Origin.

可以在训练的时候,给出一个变化的对象来定义个返回的模板坐标原点。算法在尝试定位实时图片前,可以提供一个在训练中进行的变换,通过这个变换先获取变化需要的相对的变换结果。

3 Pattern Training Information Strings

下表,显示的是PatMax算法给出的一些问题反馈编号的定义和意义,这个为诊断匹配失效有帮助。


原文地址:https://blog.csdn.net/yellow_hill/article/details/142455887

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!