多个堆栈的平均数

问题描述:

如何一次平均多个堆栈?理想情况下使用像ImageJ这样的GUI工具?我想在大约10-20个堆栈上做到这一点:1500x1500像素,500片,每个堆栈中有1个通道。一次加载所有这些将会推动我的RAM的极限。作为一个输出,我想要一个堆栈(1500x1500像素,500个切片,1个通道),其强度平均在不同的堆栈上。多个堆栈的平均数

ImageJ似乎限于一次平均2个堆栈。

我希望所有堆叠的平均重量在最终平均值。

理想情况下使用像imageJ一样的GUI工具?

关于使用的ImageJ并没有涉及到任何一段代码的问题是题外话上stackoverflow.com和应在ImageJ forum是最好问。

我该如何一次平均多个堆栈?

ImageJ中,你可以建立从堆栈一个hyperstack(例如,通过使用图像>栈>工具>串连...然后图像> Hyperstacks>栈Hyperstack ...)并随后创建平均投影(图像>叠加> Z项目...)。 要完成您的任务,您应该将每个堆叠的500个切片分配给维度,并且要平均的维度应为z

希望有所帮助。

我有太多的堆栈将它们组合成一个大的hyperstack。我内存不足了。

我结束了使用Python来代替:

import tkFileDialog 
import os 
import matplotlib.pyplot as plt 
from PIL import Image 
import numpy as np 
import glob 
from tifffile import imsave 

#select a directory containing tif-stacks to process 
#tif-stacks must have equal dimensions 

sd=tkFileDialog.askdirectory() 

#list of files to process 
fl= glob.glob(os.path.join(sd,'*.tif')) 

#number of files to process 
n_files=np.shape(fl)[0] 

im = Image.open(fl[0]) 

#get number of frames in first file by seeking all frames until error occurs 
#this seems clunky but is very fast 
#assuming same number of frames for all files 
n = 0 
while True: 
    n += 1 
    try: 
     im.seek(n) 
    except: 
     break 
n_frames=n 

#loop through all images, 
#read each frame and accumulate frame-wise sum over all stacks 

w, h = im.size 
temp = np.zeros((h,w,n_frames), dtype=np.int32) 

for i in range(n_files): 
    print 'processing file: ', i 
    im = Image.open(fl[i]) 

    for n in range (n_frames): 
     curframe = np.array(im.getdata()).reshape(h,w) 
     temp[:,:,n] += curframe 
     im.seek(n) 
     print ['frame: ', n],"   \r", 

avgStack=temp/n_files