-1
是否有一種簡單的方法用圖像兩側的x軸和y軸繪製像素強度平均值的2D數據?類似於seaborn的jointplot
(doc),但使用2D numpy陣列作爲輸入?或者,也許numpy數組可以很容易地轉換成可以散點圖的形式?沿着python中的圖像陣列軸的平均投影
醜陋的解決方法是將圖像轉換爲x和y座標。然後,我可以使用jointplot
,但圖像輸出非常難看。
img=#some 2d image data
xx=np.zeros(img.sum())
yy=np.zeros(img.sum())
i=0
for x in range(img.shape[0]):
for y in range(img.shape[1]):
for c in range(img[x,y]):
xx[i]=x
yy[i]=y
i+=1
import seaborn as sns
sns.jointplot(yy,xx)
目前還不清楚你的期望沿x或y軸的像素強度直方圖。你能詳細說明一下嗎? – kazemakase
我在這裏找到了一個相當不錯的解決方案:http://stackoverflow.com/questions/20525983/matplotlib-imshow-a-2d-array-with-plots-of-its-marginal-densities – jlarsch
不像seaborn那麼光滑,但一個好的開始 – jlarsch