/* This macro tests the workaround in ImageJ 1.50e for a bug in Java 8 on Mac OSX that causes macros not running in batch mode to slow down over time. In ImageJ 1.50e and later, when a macro is running, the ImageJ menu is not set (displayed at the top of the screen) when an image window is activated. Java 1.6/1.50d/batch mode: 1.3 Java 1.6/1.50e/batch mode: 1.3 Java 1.6/1.50d: 81.2 Java 1.6/1.50e: 9.6 Java 1.8/1.50d/batch mode: 1.2 Java 1.8/1.50e/batch mode: 1.2 Java 1.8/1.50d: 56, 116, 207 Java 1.8/1.50e: 24.2 Author: Brandon Hurr */ setBatchMode(true); run("Lena (68K)"); lena = getTitle(); selectWindow(lena); totalTime = 0; 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; totalTime += timeDiff; if (z==0) print(""); print(z, timeDiff); } print(totalTime/1000+" seconds");