其他分享
首页 > 其他分享> > 基于Halcon学习的基于灰度值模板匹配【一】exhaustive_match.hdev例程

基于Halcon学习的基于灰度值模板匹配【一】exhaustive_match.hdev例程

作者:互联网

* 模板与图像的匹配
read_image (Image, 'fabrik')
gen_rectangle1 (Rectangle, 365, 300, 390, 330)
*将图像的定义域缩小为创建的区域
reduce_domain (Image, Rectangle, Pattern)
dev_set_color ('red')
*匹配需要一段时间
stop ()

*‘dfd’方法 输出图片中灰度值偏低的位置 匹配效果最好 0则为完全匹配。
exhaustive_match (Image, Image, Pattern, ImageMatchDfd, 'dfd')
*使用全局阈值分割图像
threshold (ImageMatchDfd, MatchesDfd, 0, 5)
stop ()

 

 

*使用 ‘norm_correlation’方法 输出图片中灰度值偏高的位置 匹配效果最好 255则为完全匹配
exhaustive_match (Image, Image, Pattern, ImageMatchCorr, 'norm_correlation')
*使用全局阈值分割图像
threshold (ImageMatchCorr, MatchesCorr, 253, 255)


总代码:

 

* 模板与图像的匹配
read_image (Image, 'fabrik')
gen_rectangle1 (Rectangle, 365, 300, 390, 330)

*将图像的定义域缩小为创建的区域
reduce_domain (Image, Rectangle, Pattern)
dev_set_color ('red')

*匹配需要一段时间
stop ()

*‘dfd’方法 输出图片中灰度值偏低的位置 匹配效果最好 0则为完全匹配。
exhaustive_match (Image, Image, Pattern, ImageMatchDfd, 'dfd')
*使用全局阈值分割图像
threshold (ImageMatchDfd, MatchesDfd, 0, 5)
stop ()

*使用 ‘norm_correlation’方法 输出图片中灰度值偏高的位置 匹配效果最好 255则为完全匹配
exhaustive_match (Image, Image, Pattern, ImageMatchCorr, 'norm_correlation')
*使用全局阈值分割图像
threshold (ImageMatchCorr, MatchesCorr, 253, 255)

标签:基于,匹配,例程,Pattern,Image,灰度,图像,exhaustive
来源: https://blog.csdn.net/BoomBiuBiu/article/details/122523657