Login  Register

Re: How to reference next image in Batch Macro

Posted by G. Esteban Fernandez on Aug 08, 2015; 4:00am
URL: http://imagej.273.s1.nabble.com/How-to-reference-next-image-in-Batch-Macro-tp5013954p5013958.html

This will prompt you for a directory and get you a list of all files in
that directory, stored in an array called 'files' (or whatever arbitrary
name you choose):

dir = getDirectory();
files = getFileList(dir);

You can then refer to consecutive files using consecutive numbers in the
array index, e.g.: files[0] and files[1].
Use a for loop to go through the entire list:

for(i = 0; i < files.length - 1; i++){
     open(dir + files[i]);
     open(dir + files[i+1]);
}

-Esteban
On Aug 7, 2015 10:29 AM, "Anish Prasanna" <[hidden email]> wrote:

> Hi all,
> I am working on a project that requires me to do image subtraction on
> consecutive images in a folder. I wanted to automate this task. However, I
> am not totally sure as to how to access the next image in the folder and
> subtract it from the current image in process through the batch macro.
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/How-to-reference-next-image-in-Batch-Macro-tp5013954.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html