我创建了一个宏(基于我见过的不同宏),它可以分析图片中的粒子区域,自动将结果窗口中的区域列复制到剪贴板,并显示一个窗口询问我是否要关闭所有窗口。
我想知道是否可以将此宏应用于在 ImageJ 中打开的图片并在单个结果窗口中获取所有结果(主要是区域)。我无法使用批处理功能,因为我的文件夹包含必须彼此分开分析的图片集(不同的微生物菌株),以便分别获取每个菌株的结果。
这是我目前的宏,我知道它很丑陋,但效果相当好:
run("8-bit");
run("Threshold...");
waitForUser;
getThreshold(lower,upper);
if (lower==-1)
exit("Threshold was not set");
run("Convert to Mask");
run("Fill Holes");
run("Set Scale...", "distance=2.87 known=1 unit=µm global");
run("Analyze Particles...", "size=30-Infinity display exclude add");
close();
closeWin("ROI Manager");
closeWin("Threshold");
closeWin("Log");
String.resetBuffer;
for (i=0; i<nResults; i++)
String.append(getResult("Area", i) + "\n");
String.copy(String.buffer);
waitForUser("Work done", "WORK DONE: Close all windows?");
if (isOpen("Results")) {
selectWindow("Results");
run("Close" );
function closeWin(winName)
{
if (isOpen(winName))
{
selectWindow(winName);
run("Close");
}
}
答案1
最后我成功了,如果有人感兴趣的话,这里是代码:
for (i=1; i<=nImages; i++) {
selectImage(i);
run("8-bit");
run("Threshold...");
waitForUser;
getThreshold(lower,upper);
if (lower==-1)
exit("Threshold was not set");
run("Convert to Mask");
run("Fill Holes");
run("Set Scale...", "distance=2.87 known=1 unit=µm global");
run("Analyze Particles...", "size=30-Infinity display exclude add");
}
close("*");
closeWin("ROI Manager");
closeWin("Threshold");
closeWin("Log");
String.resetBuffer;
for (i=0; i<nResults; i++)
String.append(getResult("Area", i) + "\n");
String.copy(String.buffer);
waitForUser("Work done", "WORK DONE: Close all windows?");
if (isOpen("Results")) {
selectWindow("Results");
run("Close" );
function closeWin(winName)
{
if (isOpen(winName))
{
selectWindow(winName);
run("Close");
}
}