擅长:python、mysql、java
<p>应用</p>
<pre><code>img = img - img.mean()
temp = temp - temp.mean()
</code></pre>
<p>在计算二维互相关之前<code>corr</code>应该给出预期的结果</p>
<p>清理代码,以获取完整示例:</p>
<pre class="lang-py prettyprint-override"><code>from imageio import imread
from matplotlib import pyplot as plt
import scipy.signal as sp
import numpy as np
img = imread('https://i.stack.imgur.com/JL2LW.png', pilmode='L')
temp = imread('https://i.stack.imgur.com/UIUzJ.png', pilmode='L')
corr = sp.correlate2d(img - img.mean(),
temp - temp.mean(),
boundary='symm',
mode='full')
# coordinates where there is a maximum correlation
max_coords = np.where(corr == np.max(corr))
plt.plot(max_coords[1], max_coords[0],'c*', markersize=5)
plt.imshow(corr, cmap='hot')
</code></pre>