只是一点背景知识:
我创建了一个斐济(只是ImageJ)宏,它采用扫描图像的文件夹(6mm板以3 * 4方式对齐)识别这些ROI(板)并将它们分成单独的图像。然后比较这些单个图像以进行差异图像分析,并将结果存储为excel电子表格。这个目的是在一天结束时激活,并在一夜之间处理。
我的问题是,斐济的记忆慢慢填满然后抛出一个错误,停止了程序。我的代码中有垃圾收集,但它从来没有完全清除内存,这就是为什么慢慢填充容量。
我真的希望这可以在大多数机器上工作(因此购买更多内存不是真正的选择)我在目前的测试机上有8GB的RAM和分配给FIJI的3/4。
以下是我认为问题所在的代码。 (这是比较各个图像的宏的最后一步)非常感谢任何帮助:)
function jakero(startdir, enddir){
path = getFileList(startdir);
for(i=0; i<path.length; i++){
open(startdir+path[i]);
print(path[i]);
if(i%2){
run("Images to Stack", "name=stack1 title=[] use");
wait(1000);
//create the image difference between the sequential scans
selectWindow("stack1");
run("Image Stabilizer", "transformation=Affine maximum_pyramid_levels=4 template_update_coefficient=0.90 maximum_iterations=20000 error_tolerance=0.0000001");
run("Collect Garbage");
run("Z Project...", "start=1 stop=2 projection=[Max Intensity]");
imageCalculator("Difference create", "stack1","MAX_stack1");
selectWindow("MAX_stack1");
wait(2000);
run("Close");
run("Collect Garbage");
wait(100);
selectWindow("Result of stack1");
wait(2000);
run("Gaussian Blur...", "sigma=2 stack");
wait(2000);
//for tif was 5000 3500
run("Hysteresis...", "high=30 low=10");
wait(8000);
selectWindow("Result of stack1");
wait(100);
run("Close");
wait(100);
selectWindow("Hysteresis");
wait(100);
rename("Result of stack1");
wait(100);
run("Invert");
wait(2000);
run("Properties...", "channels=1 slices=1 frames=1 unit=mm pixel_width=0.0105834 pixel_height=0.0105834 voxel_depth=25.4000508 frame=[0 sec] origin=0,0");
wait(2000);
run("Analyze Particles...", "size=0.005-0.8 circularity=0.08-0.8 show=Nothing display exclude clear add");
selectWindow("stack1");
run("Select All");
roiManager("Combine");
//saveAs("Tiff", enddir);
selectWindow("Result of stack1");
close();
run("Collect Garbage");
close();
run("Collect Garbage");
fileName = split(path[i-1],".");
saveAs("Results", ""+enddir+""+fileName[0]+".xls");
k=1;
for (k=1; k<=5; k++) {
run("Collect Garbage");
call("CollectGarbage_.registerCloseListener");
};
}
}
}