我尝试用斐济编写一个非常简单的宏,以便合并通道并自动增强对比度。
dir = getDirectory("Select input directory"); out = getDirectory("Select destination directory");
files = getFileList(dir);
//foreach tiff couple files
for (j=0; j<lengthOf(dir);j+2) {
channel1 = dir+files[j];
channel2 = dir+files[j+1];
open(channel1);
open(channel2);
run("Enhance Contrast", "saturated=0.35"); // the same for the channel1
run("Apply LUT", "stack"); // the same for the channel1
run("Merge Channels...", "c1="+channel1+" c2="+channel2);
run("Z Project...", "projection=[Sum Slices]");
saveAs("Tiff", out+"merge"+files[j]);
run("Close");
}
使用"增强对比度",我不知道如何使用宏中亮度和对比度窗口的"自动"按钮。通道 2 比第一个更强。
使用"应用 LUT"时,当我有这一行时会发生错误:"必须首先使用图像>调整>亮度/对比度或使用图像>调整>阈值定义的阈值级别更新显示范围。我更改了阈值级别,但它仍然不起作用...
你能对我提出什么建议?
如果显示最小值和最大值为 0 和 255,则"应用 LUT"命令(源)会给出此错误。如果您的图像已经具有高对比度,则可能会发生这种情况。下面我使用 getMinAndMax
添加了一个条件,如果显示范围不变(即 0-255),它将跳过应用步骤。
使用"增强对比度",我不知道如何使用宏中亮度和对比度窗口的"自动"按钮。
根据文档,run("Enhance Contrast", "saturated=0.35")
与在B&C窗口中单击"自动"相同。
我不清楚您是要对所有图像重复此过程还是仅对第二个通道重复此过程。下面是一个宏,它分别增强了每个通道的对比度,并修复了循环的一些问题。
dir = getDirectory("Select input directory"); out = getDirectory("Select destination directory");
files = getFileList(dir);
//foreach tiff couple files
for (j=0; j<lengthOf(files);j+=2) { //fixed loop length and incrementor
channel1 = dir+files[j];
channel2 = dir+files[j+1];
open(channel1);
image1 = getTitle(); // get the window name
open(channel2);
image2 = getTitle(); // get the window name
selectWindow(image1); // focus on the first channel
run("Enhance Contrast", "saturated=0.35 process_all"); // process all slices
getMinAndMax(min,max); // get display range
if (min != 0 && max != 255) { // check if the display has been changed
run("Apply LUT", "stack");
}
selectWindow(image2); // repeating for the 2nd channel
run("Enhance Contrast", "saturated=0.35 process_all"); // process all slices
getMinAndMax(min,max); // get display range
if (min != 0 && max != 255) { // check if the display has been changed
run("Apply LUT", "stack");
}
run("Merge Channels...", "c1="+image1+" c2="+image2); // use window names rather than full paths
run("Z Project...", "projection=[Sum Slices]");
saveAs("Tiff", out+"merge"+files[j]);
run("Close All"); // make sure everything is closed
}