Posted by
JimmiB on
Aug 12, 2013; 7:07am
URL: http://imagej.273.s1.nabble.com/Memory-Problems-in-Fiji-using-macro-setBatchMode-true-tp5004321p5004388.html
Hi all,
I believe I am having a similar issue to this. I am running a macro designed to open an image crop out 2 ROI's resize one of them and save the new images. The process works fine in both ImageJ and Fiji except that it rapidly builds up memory usage.
I have tried incorporating the suggested
run("Collect Garbage"); in Fiji
All this has done is slow down the processing, but the memory issue is still there.
I am running the latest nightly build of ImageJ.
Any help would be greatly appreciated.
The macro in question is below.
Cheers,
James
macro "seperate channels[s]"{
dir1 = getDirectory("Choose Source Directory ");
dest = getDirectory("Choose Destination Directory ");
list = getFileList(dir1);
greendir = dest + "greenTEMP"+File.separator;
reddir = dest + "redTEMP"+File.separator;
//print(greendir);
File.makeDirectory(greendir);
File.makeDirectory(reddir);
x=getString("set x offset", 3);
y=getString("set y offset", 1);
setBatchMode(true);
for (i=1; i<list.length; i++) {
print (dir1+list[i]);
if (endsWith(list[i],".tif")){
showProgress(i+1, list.length);
open (dir1+list[i]); //open image i
rename ("original" + i);
run("Rotate 90 Degrees Right");
//define Green Channel
w=getWidth()-16;
h=getHeight()/2-10;
makeRectangle(x, y, w, h);
run("Duplicate...", "title=Green");
saveAs("Tiff", greendir+"green_"+i+".tif");
close("Green");
//define red channel
selectWindow("original"+i);
w_red=w/1.975*2;
h_red=h/1.985*2;
makeRectangle(3, 10+h_red, w_red, h_red);
run("Duplicate...", "title=Red_Original");
run("Scale...", "x=1.975 y=1.985 interpolation=Bicubic create title=Red_Engorged");
close("Red_Original");
run("Scale...", "x=0.5 y=0.5 interpolation=Bilinear average create title=Red");
close("Red_Engorged");
selectWindow("Red");
run("Rotate... ", "angle=0.25 grid=2 interpolation=Bilinear stack");
saveAs("Tiff", reddir +"red_"+i+".tif");
close("Red");
close("original" + i);
run("Collect Garbage");
}
}
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html