
我創建了一個巨集(基於我見過的不同巨集),用於分析圖片中的粒子區域,自動將結果視窗中的「區域」列複製到剪貼簿,並顯示一個窗口,詢問我是否要關閉每個視窗。
我想知道是否可以將此巨集應用於在 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");
}
}