opencv matchtemplate源码中用什么方法处理彩色图像?

What method is used in opencv matchtemplate source code to process color images?

opencv matchtemplate的documentation说的是

In case of a color image, template summation in the numerator and each sum in the denominator is done over all of the channels and separate mean values are used for each channel. That is, the function can take a color template and a color image. The result will still be a single-channel image, which is easier to analyze.

我不明白这是什么意思。对于颜色模板和彩色图像,单通道图像(结果)是所有通道结果的平均值吗?

templmatch.cpp源代码:github

查看matchTemplate中使用的convolve_32F函数的源码,似乎彩色图像的模板匹配实际上是将彩色图像和彩色模板转换为灰度图像,三倍在将图像和模板之间的卷积应用为灰度图像之前的许多列。

为了说明如何转换为灰度图像,请考虑以下具有 4 个颜色像素(用 BGR 值写入)的 2x2 图像:

(1, 2, 3) (4, 5, 6)
(7, 8, 9) (10,11,12)

变成如下2x6的灰度图:

(1)  (2)  (3)  (4)  (5)  (6)
(7)  (8)  (9)  (10) (11) (12)

他们像处理灰度图像一样进行卷积,然后从结果图像中取三取一来提取结果(相当于提取彩色图像的第一个通道)。