如何通过图像j宏平均文件夹中的所有文件

时间:2017-10-24 13:34:57

标签: average imagej-macro

嘿我是ImageJ宏编程的新手,我想平均文件夹中的所有图像,将单个平均图像保存在单独的文件夹中

1 个答案:

答案 0 :(得分:0)

假设您的图像按逻辑顺序排列(例如,image001,image002,image003等...) - 试试这个:

setBatchMode(true);

//retrieve images from directory
dir = getDirectory("Choose a directory of images...");
list = getFileList(dir);

for (i=0; i <list.length; i++) {
    path = dir + list[i];
    open(path); 
}
run("Images to Stack", "name=Stack title=[] use");
stackImage = getTitle();

//make an average intensity image
run("Z Project...", "projection=[Average Intensity]");

//save out to new folder
outputPath = dir + File.separator + "separateFolder";
if (!File.exists(outputPath)) File.makeDirectory(outputPath);
newPath = outputPath + File.separator + "averagedImage";
run("Save","save=[newPath]");
close(stackImage);
close();

setBatchMode(false);