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

How to average all files within a folder by image j macro

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

假设您的图像按逻辑顺序排列(例如 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);