Been using ImageJ for quite a few years on my Macs and up until last year sometime things were usually running very smoothly. A lot of macros that I use are what I call semi-automatic in that they cannot run in batch mode and often require user input to complete successfully. I am often processing 100s of images this way.
What’s been happening lately is that out of batch mode things gradually slow down over time. I do know that out of batch mode things run much slower than in batch mode, but it seems like there is a lot more to it, because before upgrading to Java 7/8 and Yosemite/El Capitan things used to be much better and faster.
I’ve written a simple script that takes an image, processes it with a color threshold and then repeats this 5 times. It has a lot of duplications and closes all but the initial image every loop and spits out the time it took for that loop.
When running in batch mode, the time is really consistent at about 70 ms, but out of batch mode, it takes a long time and the time increases. I only ran the loopt five times because if I run it much more than that, it bogs FIJI all the way down and I can’t even kill the macro easily. Menus take a while to refresh… it’s a mess.
I know that Chris in his ImageJ talk this year mentioned that there were Mac issues and I think I’m hitting my head against them. This does not happen on my work laptop (which is generally too slow for image analysis).
I’m running this in FIJI with ImageJ (daily) and ImageJ 1.50d and the results are fairly consistent.
In Batch mode (in ms):
66
69
72
66
68
Not in Batch mode (in ms):
12047
24985
37997
48017
68231
I am running Java 8, update 60 and have tried it with update 66. Similar results. My Mac is an iMac with 4-core i7 at 3.2 Ghz. It is not a “slow” computer.
My work windows laptop is a mobile i5 and I’m unsure of the speed. It has Java 1.7.0_71 32 bit ImageJ 1.50d
batchmode
452
250
109
125
140
batchmode off
679
613
711
549
563
//load lena.jpg
lena = getTitle();
selectWindow(lena);
setBatchMode(true);
for (z=0; z<5; z++) {
startTime = getTime();
run("Duplicate...", "title=painted");
run("Duplicate...", "title=colorthresholdsomething");
selectWindow("colorthresholdsomething");
// Color Thresholder 2.0.0-rc-39/1.50b
// Autogenerated macro, single images only!
min=newArray(3);
max=newArray(3);
filter=newArray(3);
a=getTitle();
run("RGB Stack");
run("Convert Stack to Images");
selectWindow("Red");
rename("0");
selectWindow("Green");
rename("1");
selectWindow("Blue");
rename("2");
min[0]=0;
max[0]=23;
filter[0]="pass";
min[1]=0;
max[1]=18;
filter[1]="pass";
min[2]=126;
max[2]=255;
filter[2]="pass";
for (i=0;i<3;i++){
selectWindow(""+i);
setThreshold(min[i], max[i]);
run("Convert to Mask");
if (filter[i]=="stop") run("Invert");
}
imageCalculator("AND create", "0","1");
imageCalculator("AND create", "Result of 0","2");
for (i=0;i<3;i++){
selectWindow(""+i);
close();
}
selectWindow("Result of 0");
close();
selectWindow("Result of Result of 0");
rename(a);
// Colour Thresholding-------------
run("Convert to Mask");
invertedLUT = is("Inverting LUT");
if (invertedLUT == 1) {
run("Invert LUT");
run("Invert");
}
run("Options...", "iterations=8 count=1 do=Dilate");
run("Fill Holes");
run("Create Selection");
run("Close");
selectWindow("painted");
run("Restore Selection");
setForegroundColor(0, 0, 0);
run("Fill", "slice");
run("Select None");
run("Close");
endTime = getTime();
timeDiff = endTime - startTime;
print(timeDiff);
}