<h2>编辑[2019年1月]</h2>
<p>@Tashus comment bellow是正确的,因此<a href="https://stackoverflow.com/a/2448194/3026320">@dudemeister's answer</a>可能更为重要。他建议的函数也更有效,因为它避免了直接的二维卷积和需要的运算次数。</p>
<h2>可能的问题</h2>
<p>我相信您正在做两个一维卷积,第一个是每列卷积,第二个是每行卷积,并将第一个卷积的结果替换为第二个卷积的结果。</p>
<p>请注意,带<code>'same'</code>参数的<a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.convolve.html" rel="nofollow noreferrer">^{<cd1>}</a>返回一个与所提供的最大值形状相等的数组,因此在进行第一次卷积时,已经填充了整个<code>data</code>数组。</p>
<p>在这些步骤中可视化数组的一个好方法是使用<a href="https://scipy.github.io/old-wiki/pages/Cookbook/Matplotlib/HintonDiagrams.html" rel="nofollow noreferrer">Hinton diagrams</a>,这样就可以检查哪些元素已经有了值。</p>
<h2>可能的解决方案</h2>
<p>如果您的卷积矩阵是使用一维<code>H_r</code>和<code>H_c</code>矩阵的结果,那么您可以尝试添加这两个卷积的结果(使用<code>data[:,c] += ..</code>而不是第二个<code>data[:,c] =</code>循环):</p>
<p><a href="https://i.stack.imgur.com/hBO9f.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hBO9f.gif" alt="convolution core addition"/></a></p>
<p>另一种方法是对二维卷积数组使用<a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.convolve2d.html" rel="nofollow noreferrer">^{<cd9>}</a>,这可能是您最初想要做的。</p>