前言:
针对PatMax 的高级应用和原理,在这一节进行说明:
PatMax Patterns
When you train PatMax you specify a region of interest in an image or provide a description of a shape that includes the features you want to train. If you are using an image to train the PatMax software, PatMax constructs an internal geometric representation of the features that make the pattern, where features are defined by boundaries between regions of dissimilar grey values. If you are using a shape description to train the PatMax software, PatMax transforms the model information into this same internal geometric description. Once trained, PatMax execution is the same regardless of whether PatMax was trained with an image or with a shape description.
需要训练PatMax的某个需求区域的时候,首先需要提供对这个特征需求的形态的描述,这个特征形态需求包括你想训练的特征【或者说你希望未来算子自动找寻的特征】。当使用一个1图像进行训练的时候,PatMax构建了一个内部的几何表达,并利用这些几何表达来构建模板。【案,主要是通过不同区域灰度值的边界表达来区分模板的特征区域】。PartMax也可以通过,2形状的描述,对于形态描述,PatMax将模型的信息同样投射到相同几何的表述里面去。【案,也就是最终用几何的表述来描述特征匹配模版,不因为选择图像,或者形状而改变】
Pattern Features 模板特征
模板特征,理解为一组特征值的集合。一个独立的特征往往被有区分度的连续的像素的边界点击区域来定义。【案,这些区分度的定义,可以是亮度、对比度、纹理等任何最终反映到像素边界的区域】区域的定义可以是闭合的,也可以是开放的。
PatMax pattern features are represented by an ordered list of feature boundary points. A feature boundary point has a location and an angle along with links to its neighboring boundary points. The angle of a feature boundary point is the angle between the image coordinate system x-axis and a line drawn through the feature boundary point perpendicular to the feature boundary and in the dark-to-light direction.
PatMax算子,简单的模板特征的计算原理,是通过一个带次序的边界点集来表达的。而一个特征的边界点集包括两个重要的特性:1 位置 2 和相邻的点的角度【这一点的定义后面用图来进一步阐述】,特征边界点的角度,是在图像坐标系中,以X轴正向为起点,然后,按照dark-to-light延伸的角度【案,这里角度的定义是dark-to-light,也就是定义一个规则,规则为灰度暗的区域向灰度浅的区域的正交(90度)延伸。如下图:
Feature Size and Pattern Granularity 特征尺寸和粒度
The features that make up a pattern can be of different sizes, from features a few pixels in size to features up to 50 or 100 pixels in size. Most patterns contain features with a range of sizes.PatMax uses features of different sizes to locate the desired features in the run-time images you acquire. In general, PatMax uses large features to find an approximate pattern match in a run-time image quickly, and small features to determine the pattern location precisely.
Figure 6. Large features used for coarse location and small features for fine location
PatMax算子的逻辑,如上,就是将模板特征依据大小【案,这里应该是点集的大小】分为Large和Small,然后,利用大的特征点集来找到近似的模板,在用小的特征去进一步决定匹配模版的位置精度。
The particular features that PatMax can detect in an image are determined by the granularity the PatMax software is currently using. Large granularity settings allow the software to detect only large features in an image, while a smaller granularity setting allows the tool to locate smaller features.
1 粒度的定义:
In addition to affecting the features that are trained as part of the pattern, pattern granularity also affects the spacing of boundary points along a feature boundary. In general, the spacing of feature boundary points is approximately equal to the pattern granularity.
PatMax uses a range of pattern granularities when it trains a pattern from an image; PatMax automatically determines the optimum granularity settings when it trains a pattern. The smallest granularity used to detect features in the training image or shape description is called the fine granularity limit. The largest granularity used to detect features is called the coarse granularity limit.You can display the actual features and feature boundary points trained using the 1 coarse and 2 fine granularity limits.
Note: PatMax trains the pattern using a range of granularities, not just the coarse and fine granularity limits. The coarse and fine limits are the largest and smallest granularities that PatMax uses.
[PatMax 算子是在最大粒度和最小粒度之间的一个范围内来训练特征的模板]
Pattern Polarity 模板的极性
Each of the boundary points that describes a pattern feature has a polarity. The polarity of a boundary point indicates whether the boundary can be characterized as1 light-to-dark or 2 dark-to-light. You can configure PatMax to find only objects in which every boundary point has the same polarity as the trained pattern, or you can configure PatMax to find objects with mismatched polarity.
一个包含某个特征的模板,特征的表达分为两种,这里定义为: 1 light-to-dark or 2 dark-to-light
上图,绿框为:dark-to-light, 红框为light-to-dark,
【案,PatMax的特征模板训练,如左图,如果我们想要绿框的结果,那么,需要在配置算子的时候,选择Matching polarity,否则,选择Mismatched polarity。】
Pattern Masking
这个算子的功能比较简单:就是屏蔽掉你不想处理的部分。
Note: Pattern masking is not supported for shape training since you can design your shape description to include only desired features and thus have no need to mask out unwanted features.
The mask image is interpreted as follows:
- All pixels in the training image that correspond to pixels in the mask image with values greater than or equal to 192 are considered care pixels. All feature boundary points detected within care pixels are included in the trained pattern.
- All pixels in the training image that correspond to pixels in the mask image with values from 0 through 63 are considered don't care but score pixels. Feature boundary points detected within don't care but score pixels are not included in the trained pattern. When the trained pattern is located in a run-time image, features within the don't care but score part of the trained pattern are treated as clutter features.
- All pixels in the training image that correspond to pixels in the mask image with values from 64 through 127 are considered don't care and don't score pixels. Feature boundary points detected within don't care and don't score pixels are not included in the trained pattern. When the trained pattern is located in a run-time image, features within the don't care and don't score part of the trained pattern are ignored and not treated as clutter features.
- Mask pixel values from 128 through 191 are reserved for future use by Cognex.
【案,Masking 功能在Shape的模板判别的时候是不使能的。 现在看Mask也是通过灰度的值来决定,这里的阈值大约在192这个大小】
这个逻辑同时包括,dark-to-light的基本定义,边缘的定义以黑色为默认。
有关不同的灰度定义下的逻辑:
- >= 192 的区域被认为被搜索,或者成为训练区域,这里会对图像的所有特征进行检测
- 0 到 63的高亮区域,为不考虑,但是积分(score pixels)像素区域。【案,PatMax算法有一个计分的因子,用于评判特征匹配的相似程度,这里我理解的积分的区域,是在做特征匹配度的评分的时候,会考虑0到63的区域用于评分。这应该该是一个参考的分数。】,score pixels 影响的特征判断的特征,这里定义为 clutter features【案,理解为其他(凌乱)的小特征】
- 64到127的灰度区域,也是mask在设定的时候,我们看到的区域,会被任务是不需要处理的像素点区域。
- 128 到 191的区域是康耐视软件预留的区域
【案,康耐视的掩膜的定义,显然,和灰度的定义有相关性,但是,感觉有点不同,这里面混杂了处理的逻辑,这一点是不是很好,我想值得商榷】