模板匹配——set_shape_model_clutter

通过设置杂波,来准确定位要检测对象;

如下图中未设置杂波情况下,匹配结果如(3);如图(4)设置杂波后,匹配结果如图(5)

复制代码
*
* Create a shape model.
*创建一个模型
read_image (ImageModel, '/bga_gap/bga_gap_01.png')
gen_circle (ROI, 753.869, 551.624, 28.4027)
reduce_domain (ImageModel, ROI, ImageReduced)
create_aniso_shape_model (ImageReduced, 'auto', rad(0), rad(0), 'auto', 0.95, 1.05, 'auto', 0.95, 1.05, 'auto', 'auto', 'use_polarity', 'auto', 'auto', ModelID)
*
* Specify the clutter parameters.
*指定待筛选杂波参数
find_aniso_shape_model (ImageModel, ModelID, rad(0), rad(0), 0.95, 1.05, 0.95, 1.05, 0.83, 0, 0.0, 'least_squares', 0, 0.0, Row, Column, Angle, ScaleR, ScaleC, Score) 
*获取匹配结果
get_hom_mat2d_from_matching_result (Row[0], Column[0], Angle[0], ScaleR[0], ScaleC[0], HomMat2D)  
* 
gen_circle (ROI_0, 700.655, 548.666, 21.6273)
gen_circle (ROI_1_0, 810.655, 550.611, 21.6273)
union2 (ROI_0, ROI_1_0, ClutterRegion)
*
ClutterContrast := 12
*
* Set the clutter parameters into shape model.
*查找模型设置杂波参数
set_shape_model_clutter (ClutterRegion, ModelID, HomMat2D, ClutterContrast, [], []) 
*
* Use the shape model to detect objects with a small amount of clutter
*使用形状模型检测具有少量杂波的对象
read_image (Image,'/bga_gap/bga_gap_02.png')
MaxClutter := 0.09
find_aniso_shape_model (Image, ModelID, rad(0), rad(0), 0.95, 1.05, 0.95, 1.05, [0.83, MaxClutter], 0, 0.0, 'least_squares', [4, 3],  0.0,  Row, Column, Angle, ScaleR, ScaleC, Score)
*
* Visualize the matches
dev_display_shape_matching_results (ModelID, ['green', 'red'], Row, Column, Angle, ScaleR, ScaleC, 0)
Clutter := Score[|Score|/2:|Score|-1]
Score := Score[0:|Score|/2-1]
dev_inspect_ctrl ([Score, Clutter])
复制代码

 

posted @   echo-efun  阅读(166)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示