我正在尝试使用 mplot3d 模块在 3d 中绘制 2D 曲面图。
我知道如何“手动”找到最大值及其位置(就行和列而言),这对我正在做的事情非常重要。有没有办法将这些信息绘制到峰值上?也就是说,在峰值旁边写 (maxval,row,col) ?
PS当我问这个时。也许有一种简单的方法可以识别第二个峰值(或任何其他峰值?)。我目前正在使用掩码,以掩盖第一个峰并找到第二个峰,但我必须非常小心选择边,因为如果我碰巧掩码太少,一些非峰的东西会被识别出来作为一个峰值,将无法识别真正的第二个峰值,从而扰乱了称为“峰峰值”信噪比的测量。
我目前使用的代码是:
frame_a = gdal.Open( "frame_{0:05d}.tif".format(274) ).ReadAsArray()
# in case this helps, this is how the images are read, they are 16-bit GS tiffs.
frame_b = gdal.Open( "frame_{0:05d}.tif".format(287) ).ReadAsArray()
#this does some clever stuff but basically it returns a 2-D 32x32 array.
corr = correlate_windows( windows_a[99], windows_b[99], corr_method = corr_method, nfftx=nfftx, nffty=nffty )
#this is how I find the position of max value.
column = np.argmax(np.max(corr, axis=0))
row = np.argmax(np.max(corr, axis=1))
maximum = corr.max()
print 'column = ' + str(column)
print 'row = ' +str(row)
print 'peak_1 = ' + str(maximum)
import matplotlib.cm as cmps
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.ticker import LinearLocator, FormatStrFormatter
fig = pl.figure()
ax = Axes3D(fig)
# window size is 32 in this case
nx, ny = window_size*2, window_size*2
xx = range(nx)
yy = range(ny)
X, Y = np.meshgrid(xx, yy)
ax.plot_surface(X , Y , corr , rstride = 1, cstride = 1 )
pl.show()