Opencv - Filter2D 函数

Opencv - Filter2D function

我想使用我自己的内核过滤图像。此过滤器的内核矩阵元素的摘要是否应等于 1?

我准备了一个内核。我试了一下,结果对我来说很好。但我不确定这个内核是否是一个真正的过滤矩阵。我看了一条评论,上面说

1 1 1
1 1 1
1 1 1

这是错误的,应该是

1.0/9 1.0/9 1.0/9 
1.0/9 1.0/9 1.0/9
1.0/9 1.0/9 1.0/9

我的内核是

0  0  0  0  0
1  2  5  2  1
0  0  0  0  0
-1 -2 -5 -2 -1
0  0  0  0  0

Should summary of kernel matrix elements of this filter is equal to 1?

如果希望卷积后的图像亮度相同,那么kernel所有元素的和应该为1,例如如果你想模糊你的形象。这称为内核规范化。总和为 0 也很常见,例如在边缘检测的情况下。

您的内核看起来像是 Sobel operator, which also sums to zero. Examples of other common convolution kernels can be found on Wikipedia.

的特例