我正在嘗試使用mplot3d模塊在3D中繪製二維曲面圖。2D三維表面圖。繪製圖上峯的指數(可能通過識別峯?)。 Python
我知道如何「手動」查找最大值及其位置(按行和列),這對我所做的事非常重要。有沒有辦法將這些信息繪製到高峯上?也就是說,在峯值旁邊寫入(maxval,row,col)?
P.S.而我正在問這個。也許有一個簡單的方法來確定第二個峯值(或其他任何峯值)?我目前使用的是面具,以掩蓋第一個高峯並找到第二個高峯,但我必須非常小心地選擇雙方,因爲如果我碰巧面具太少,一些非高峯的東西將被識別作爲一個峯值,而第二個峯值將不會被識別,從而搞亂了稱爲「峯峯值」信噪比的測量。
我目前使用的代碼是:
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()
作爲一個家務記錄,你不能包括圖像,直到你有更高的聲譽和足夠的代表你可以編輯其他職位。 – tacaswell
'鬆散對齊'是什麼意思?你能把第二張圖片放在某個地方嗎?你應該把問題的第二部分和第三部分分解成自己的問題。理想的SO線程只有一個問題,使得它們更容易回答,並使它們對未來的讀者更有用。 – tacaswell
感謝您的評論tcaswell! 我編輯了這個問題。 我想在問題的其他部分(現在刪除)中查找的內容實際上是修復了圖上的「視點」(在上圖中,您無法真正看到零是哪裏)。我認爲這應該很容易找到。 –