我是 ImageJ 的新手,但正在尝试了解有关编写宏的更多信息。
我有以“10Xred.tif”、“10Xgreen.tif”、“10Xblue”和“10Xlr.tif”结尾的图像。我想使用不同的参数处理每种颜色。
我编写的代码仅将所有文件从输入文件夹传输到输出文件夹,而不对其进行处理。我不确定问题出在哪里。
如果这个问题可能很乏味或不适合论坛目的,我深表歉意 - 非常感谢任何和所有建议!
谢谢你。
input = getDirectory("Input directory");
output = getDirectory("Output directory");
Dialog.create("File type");
Dialog.addString("File suffix: ", ".tif", 5);
Dialog.show();
suffix = Dialog.getString();
processFolder(input);
function processFolder(input) {
list = getFileList(input);
for (i = 0; i < list.length; i++) {
if(File.isDirectory(list[i]))
processFolder("" + input + list[i]);
if(endsWith(list[i], suffix))
processFile(input, output, list[i]);
}
}
function processFile(input, output, file) {
title = (File.getName(input));
if (indexOf(title, "10Xblue") >= 0) {
run("Channels Tool...");
run("Blue");
run("Subtract Background...", "rolling=50");
run("Multiply...", "value=1.2");
run("Set Scale...", "distance=1 known=0.65 pixel=1 unit=µm global");
run("Scale Bar...", "width=100 height=5 font=18 color=White background=None location=[Lower Right] bold overlay");
run("RGB Color");
run("Flatten"); }
else if (indexOf(title, "10Xred") >= 0) {
run("Channels Tool...");
run("Red");
run("Subtract Background...", "rolling=50");
run("Multiply...", "value=1.350");
run("Scale Bar...", "width=100 height=5 font=18 color=White background=None location=[Lower Right] bold overlay");
run("RGB Color");
run("Flatten");}
else if (indexOf(title, "10Xgreen") >= 0) {
run("Channels Tool...");
run("Green");
run("Subtract Background...", "rolling=50");
run("Multiply...", "value=1.250");
run("Scale Bar...", "width=100 height=5 font=18 color=White background=None location=[Lower Right] bold overlay");
run("RGB Color");
run("Flatten"); }
else if (indexOf(title, "10Xlr") >= 0) {
run("Channels Tool...");
run("Magenta");
run("Subtract Background...", "rolling=50");
run("Multiply...", "value=1.200");
run("Scale Bar...", "width=100 height=5 font=18 color=White background=None location=[Lower Right] bold overlay");
run("RGB Color");
run("Flatten");
}
print("Processing: " + input + file);
open(input + file);
print("Saving to: " + output);
saveAs("TIFF", output+file);
close();
}