Loading several images

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Loading several images

Francesco De Comite
Hi all,

     I would like to write a plugin (not a macro) that read a whole
directory of images and process them in order to produce a single image
as a result.
Do I have to use a stack ? Could someone show me a piece of code for
loading several images
and prepare them for processing ?

     Regards

     F. De Comité

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Loading several images

Jan Eglinger
Hi Francesco,

 >      I would like to write a plugin (not a macro) that read a whole
 > directory of images and process them in order to produce a single
 > image as a result.

you can use the following lines in Java:

     File dir = new File(dirpath);
     File[] list = dir.listFiles();
     for (File file : list) {
         /* do your processing here */
     }

For an example see the following small plugin I wrote to temporarily
mask file names for performing "blind" analyses:

https://github.com/imagejan/imagej-plugins/blob/master/Blind_Experiment/src/main/java/imagejan/plugins/Blind_Experiment.java#L54-65

Hth,
Jan


On 17.01.2014, 3:38 PM, Francesco De Comite wrote:

> Hi all,
>
>      I would like to write a plugin (not a macro) that read a whole
> directory of images and process them in order to produce a single image
> as a result.
> Do I have to use a stack ? Could someone show me a piece of code for
> loading several images
> and prepare them for processing ?
>
>      Regards
>
>      F. De Comité
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Loading several images

Michael Schmid
In reply to this post by Francesco De Comite
Hi Francesco,

why not use the stack that you get with File>Import>Image Sequence?
With Plugins>Macros>Record, you can also record the IJ.run(...) command that you need for using this command in a plugin.
Alternatively, you could try the underlying method of ij.plugin.FolderOpener, e.g.
  ImagePlus myNewImagePlusStack = Folderopener.open(path);

If the images would need too much memory, use the virtual stack option (only available with IJ.run): Then each image is loaded into memory only if you access the corresponding stack slice.

Michael
________________________________________________________________
On Jan 17, 2014, at 15:38, Francesco De Comite wrote:

> Hi all,
>
>    I would like to write a plugin (not a macro) that read a whole directory of images and process them in order to produce a single image as a result.
> Do I have to use a stack ? Could someone show me a piece of code for loading several images
> and prepare them for processing ?
>
>    Regards
>
>    F. De Comité
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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