如果圖像中物體存在縮放,則不能使用 correlation-based matching方法。
Shape-based matching should be choosen if occlusions or clutter can not be avoided or if a matching of objects with changing color is applied.
correlation-based matching is suitable for objects with a random and changing texture or for objects with a slightly changing shape.Additionally,correlation-based matching is to be preferred when handing strongly defocused images.
Speed Up Match
- Restrict Search Space:Depending on the matching approach, this space encompasses not only the two dimensions of the image, but also other parameters like the possible range of scales and orientations or the question of how much of the object must be visible. The more you can restrict the search space, the faster the search will be.
- Image pyramid subsample:
Match Result
To locate objects in images, information like the position and orientation of the searched objects must be returned by the matching. This information is available in different representations, depending on the selected matching approach. That is, for a strict 2D matching the position and orientation are returned separately, i.e., the position consists of a row and a column value and the orientation consists of a single value describing the angle. In contrast, the uncalibrated perspective approaches return the position and orientation together in a projective transformation matrix (2D homography) and the calibrated perspective approaches return them together in a 3D pose. Besides the position and orientation, many approaches return further information like the scale of the found object or information about the quality of the match, which is called score.
基於形狀的匹配
不可縮放模板
create_shape_model(Template : : NumLevels, AngleStart, AngleExtent, AngleStep, Optimization, Metric, Contrast, MinContrast : ModelID)
create_shape_model_xld(Contours : : NumLevels, AngleStart, AngleExtent, AngleStep, Optimization, Metric, MinContrast : ModelID)
各項同性可縮放模板
create_scaled_shape_model(Template : : NumLevels, AngleStart, AngleExtent, AngleStep, ScaleMin, ScaleMax, ScaleStep, Optimization, Metric, Contrast, MinContrast : ModelID)
create_scaled_shape_model_xld(Contours : : NumLevels, AngleStart, AngleExtent, AngleStep, ScaleMin, ScaleMax, ScaleStep, Optimization, Metric, MinContrast : ModelID)
各向異性可縮放模板
create_aniso_shape_model(Template : : NumLevels, AngleStart, AngleExtent, AngleStep, ScaleRMin, ScaleRMax, ScaleRStep, ScaleCMin, ScaleCMax, ScaleCStep, Optimization, Metric, Contrast, MinContrast : ModelID)
create_aniso_shape_model_xld(Contours : : NumLevels, AngleStart, AngleExtent, AngleStep, ScaleRMin, ScaleRMax, ScaleRStep, ScaleCMin, ScaleCMax, ScaleCStep, Optimization, Metric, MinContrast : ModelID)
可方便的檢查創建模板的圖像金字塔層數和對比度參數
inspect_shape_model(Image : ModelImages, ModelRegions : NumLevels, Contrast : )
如果通過XLD創建模板,經過第一次匹配后,建議通過set_shape_model_metric()指定模板極性。
參數
Contrast
傳入1個元素時,直接提取邊緣
傳入2個元素時,表示使用磁滯分割來提取邊緣,第一個元素為上閾值,第二個元素為下閾值
傳入3個參數時,表示使用磁滯分割來提取邊緣,第三個參數表示所提取的邊緣的最小長度
Optimization
一些模板包含了太多的像素點,這導致模板過大,增加了執行時間和內存需求
none 不減少像素
point_reduction_low 大約一半點
point_reduction_medium 大約1/3
point_reduction_high 大約1/4
該參數除了可以用來減少像素,還可以用於控制模板的創建方式,來選擇是內存優先還是速度優先。
pregeneration 模板預先創建,犧牲內存來換取查找速度
no_pregeneration 在查找時才創建必須數據,占用內存少
通過set_system('pregenerate_shape_models','true'/'false')可以統一設置
MinContrast
MinContrast參數是被查找圖片的最小對比度
If the object’s rotation may vary in the search images you can specify the allowed range in the parameter AngleExtent and the starting angle of this range in the parameter AngleStart (unit: radians). Note that the range of rotation is defined relative to the reference image, i.e., a starting angle of 0 corresponds to the orientation the object has in the reference image. Therefore, to allow rotations up to +/-5 ◦ , e.g.,you should set the starting angle to -rad(5) and the angle extent to rad(10).
查找
find_shape_model(Image : : ModelID, AngleStart, AngleExtent, MinScore, NumMatches, MaxOverlap, SubPixel, NumLevels, Greediness : Row, Column, Angle, Score)
find_shape_models(Image : : ModelIDs, AngleStart, AngleExtent, MinScore, NumMatches, MaxOverlap, SubPixel, NumLevels, Greediness : Row, Column, Angle, Score, Model) 可同時搜尋多個模板
邊界處理
set_system('border_shape_models','true') 模板可以部分在ROI外
set_system('border_shape_models','false') 模板必須在ROI內
基於組件的匹配
基於組件的匹配是形狀匹配的擴展算法,只有一個組件會在整個ROI區域搜索,其余組件會根據組件之間的關聯關系去小范圍搜索。
In contrast to shape-based matching,for component-based matching no scaling in size is possible.
create_component_model()
create_trained_component_model()
train_model_components()
find_component_model()
基於灰度的(互相關)匹配
歸一化互相關系數匹配(Normalized Cross Correlation Matching,NCC),受光照變換不明顯,對於物體有輕微變形,圖像模糊、邊緣不清晰的圖片,圖片有文理的情況,使用形狀匹配比較困難,而NCC可以解決。
局部變形匹配
The result of local deformable matching differ from those of other matching approaches.Though it returns also a position and a score,it does not return an orientation or even a scale.Instead, a set of iconic objects can be returned that helps to inspect the deformations of found object instance.Depending on the selected values of ResultType,the following iconic objects are returned:RectifiedInage,VectorField,DeformedContours
Perspective Deformable Matching
Like shape-based matching, perspective deformable matching extracts contours and matches their shapes against the shapes of previously created models. But in contrast to shape-based matching, also perspectively deformed contours can be found. For the perspective deformable matching, an uncalibrated as well as a calibrated version is provided.
create_planar_uncalib_deformable_model()
create_planar_uncalib_deformable_model_xld()
find_planar_uncalib_deformable_model()
create_planar_calib_deformable_model()
create_planar_calib_deformable_model_xld()
find_planar_calib_deformable_model()
get_deformable_model_contours()
projective_trans_contour_xld()
clear_deformable_model()
Descriptor-Based Matching
Similar to the perspective deformable matching, the descriptor-based matching is able to find objects even if they are perspectively deformed. Again, the matching can be applied either for a calibrated camera or for an uncalibrated camera. In contrast to the perspective deformable matching, the template
is not built by the shapes of contours but by a set of so-called interest points. These points are first extracted by a detector and then are described, i.e., classified according to their location and their local gray value neighborhood, by a descriptor.