虽然我已经找到了关于 scipy.ndimage.convolve 函数的文档并且我“实际上知道它是做什么的”,但当我尝试计算结果数组时,我无法遵循数学公式。让我们举个例子:
a = np.array([[1, 2, 0, 0],`
[5, 3, 0, 4],
[0, 0, 0, 7],
[9, 3, 0, 0]])
k = np.array([[1,1,1],[1,1,0],[1,0,0]])
from scipy import ndimage
ndimage.convolve(a, k, mode='constant', cval=0.0)
# Why is the result like this ?
array([[11, 10, 7, 4],
[10, 3, 11, 11],
[15, 12, 14, 7],
[12, 3, 7, 0]])
Run Code Online (Sandbox Code Playgroud)
我将不胜感激逐步计算。