简体   繁体   English

彩色图像输入的模板匹配

[英]Template matching for colored image input

I have a working code for template matching.我有一个用于模板匹配的工作代码。 But it only works if the input image is converted into grayscale.但它只有在将输入图像转换为灰度时才有效。 Is it possible to do template matching considering the template color as well that needs to be found in the given image?是否可以考虑模板颜色以及需要在给定图像中找到的模板匹配?

inputImg = cv2.imread("location")
template = cv2.imread("location")

Yes, you can do it but why?是的,你可以做到,但为什么呢?

The idea of converting to the grey-scale is to apply the selected edge-detection algorithm to find the features of the input image.转换为灰度的想法是应用选定的边缘检测算法来查找输入图像的特征。

Since you are working the features the possibility of finding the template image in the original image will be higher.由于您正在使用这些功能,因此在原始图像中找到模板图像的可能性会更高。 As a result, converting to grey-scale has two advantages.因此,转换为灰度有两个优点。 Accuracy and computational complexity.准确性和计算复杂性。

The matchTemplate method is also working for the RGB images. matchTemplate方法也适用于 RGB 图像。 Now you need to find the image characteristic for 3 different channels.现在您需要找到 3 个不同通道的图像特征。 Yet you are not sure about whether your features robust or not, since most edge-detection algorithms are designed for the grey-scale images.然而你不确定你的特征是否健壮,因为大多数边缘检测算法都是为灰度图像设计的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM