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

2024-09-30 10:40:45 发布

您现在位置:Python中文网/ 问答频道 /正文

opencvmatchtemplate的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


Tags: andoftheinimageisdocumentationchannel
1条回答
网友
1楼 · 发布于 2024-09-30 10:40:45

matchTemplate中使用的convolve_32F函数的源代码来看,在将图像和模板之间的卷积应用为灰度图像之前,彩色图像上的模板匹配实际上会将彩色图像和颜色模板转换为具有三倍列数的灰色图像。在

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

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

它将变成以下2x6灰色图像:

^{pr2}$

它们执行的卷积操作与灰度图像相同,然后通过在结果图像中取三个值中的一个值来提取结果(相当于提取彩色图像的第一个通道)。在

相关问题 更多 >

    热门问题