2015-06-23 42 views
0

我有一個2D陣列img_pseudo_df,我通過imshow()繪製,並且表示一些其中每個熒光點的中心表示細胞僞熒光數據:matplotlib:散射()上imshow()上收縮顯示點座標

img = plt.imshow(img_pseudo_df.T, cmap=plt.cm.gray, interpolation='none', extent=(0.0,N_pixels,0.0,N_pixels)) 

在上面我正在固定一個先驗的數字大小到N_pixels,我轉移圖像爲了我的方便。 由此得出的數字看起來就像例如:

enter image description here

在該圖的頂部,我想覆蓋一個scatter()圖,其中每個點代表一個細胞。我傳遞散射(區間[0,N_pixels]內的每個)中的像素值xy座標:

plt.scatter(x,y) 

但是由於某種原因,這些座標似乎相對於所述熒光的在圖中的座標縮水:

enter image description here

我搞不​​清楚我做錯了什麼,以及如何獲得imshow座標與我的觀點匹配。這顯然是imshow()的一個常見問題,但目前爲止找不到適合我的答案。

特別是,xy包含行列img_pseudo_df數組的索引值。這個陣列由

img_pseudo_df = zeros((N_pixels,N_pixels)) 

最初創建然後像素(x,y)img_pseudo_df由2D高斯濾波器(以產生僞熒光appeareance)分配一定signal值和卷積:

for cell,pixel in enumerate(zip(x,y)): 
    img_pseudo_df[pixel] = signals[cell] # signals contains N cells values and there are N cells (x,y) pairs 
img_pseudo_df = convolve2d(space, gaussian_kern(20), mode='valid') 

作爲過濾器以0爲中心,由以下部分構成:

def gauss_kern(size, sizey=None): 
""" Returns a normalized 2D gauss kernel array for convolutions """ 
size = int(size) 
if not sizey: 
    sizey = size 
else: 
    sizey = int(sizey) 
x, y = mgrid[-size:size+1, -sizey:sizey+1] 
g = exp(-(x**2/float(size)+y**2/float(sizey))) 
return g/g.sum() 

我期待熒光poi nt以細胞位置(x,y)爲中心。

在此先感謝您的幫助。

乾杯,

中號

+2

如何創建'x'和'y'?難道這些值是錯的? – hitzg

+0

@hitzg謝謝你指出:我相應地編輯了我的帖子。 – maurizio

回答

0

好吧,確實在卷積錯誤。正確的選項是mode='same',以便使得出的數字匹配最初爲空的「img_pseudo_df」。

乾杯,

中號

相關問題