Posted by
dgrosen on
URL: http://imagej.273.s1.nabble.com/batch-focus-stacker-tp5022808.html
Hi. New to the forum but not to imageJ. However, I need a little help
modifying this code to do the following.
I have a folder with multiple images. Each set has 5 images from different
focal distance. I need to:
- grab the first 5, open focus stacker and save as img1.
- grab the second set of 5, open focus stacker and save as img2....
.....and so forth
I found this code here but it does not work for me. It just stacks the first
5 pictures and nothing else
Thanks
dir = getDirectory("Choose image sequence folder");
setBatchMode(true);
count = 0;
countFiles(dir);
n = 0;
processFiles(dir);
print(count+" files processed");
function countFiles(dir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
countFiles(""+dir+list[i]);
else
count++;
}
}
function processFiles(dir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
processFiles(dir+list[i]);
else {
showProgress(n++, count);
path = dir+list[i];
processFile(path);
i = list.length; // This line takes care that all
images in a directory are only analysed once
}
}
}
function processFile(path) {
for (i=0; i<list.length; i++)
open(path); // Removed a } what closed the function at this
point
run("Images to Stack", "name=Stack title=[] use");
run("Stack Focuser ", "enter=11");
saveAs("Tiff", dir+"stack");
run("Close All"); // Take care that all images are closed
--
Sent from:
http://imagej.1557.x6.nabble.com/--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html