Login  Register

Re: batch processing for a selection of images

Posted by Michael Schmid on Apr 14, 2011; 2:59pm
URL: http://imagej.273.s1.nabble.com/batch-processing-for-a-selection-of-images-tp3684989p3684993.html

Hi Ramon,

no problem, you can easily adapt the macro for the case that you want  
to create new windows:

imgArray = newArray(nImages);
for (i=0; i<nImages; i++) {
   selectImage(i+1);
   imgArray[i] = getImageID();
}

//now we have a list of all open images, we can work on it:

for (i=0; i< imgArray.length; i++) {
   selectImage(imgArray[i]);
   //do whatever you like, whether it creates new images or not.
   //e.g.
   if (nSlices() > 1)
      run("Make Montage...");
}


Michael
________________________________________________________________

On 14 Apr 2011, at 15:21, Ramon wrote:

> Hello, What if operating with all the files within a directory, you  
> want to
> separate the channels and make compositions? you should have to  
> identify the
> new windows and include in the macro to continue operating... in my  
> case I
> want to separate the channels of all the files within a directory,  
> and make
> those compositions
>
> On 14 April 011 15:13, Michael Schmid <[hidden email]> wrote:
>
>> Hi Finn,
>>
>> if you want to do some processing for all images open in ImageJ,  
>> you can
>> use a very simple macro:
>>
>> for (i=1; i<=nImages; i++) {
>>  selectImage(i);
>>  processImage();  //or simply put your processing commands here.
>> }
>>
>> function processImage() {
>>  run("Smooth");
>>  //or whatever operation(s) you like...
>>  //Make sure you leave no new images open,
>>  //and don't close the current image.
>> }
>>
>> Michael
>> ________________________________________________________________
>>
>>
>> On 14 Apr 2011, at 13:05, Finn Peters wrote:
>>
>>  Hi everyone,
>>>
>>> I wanted to ask if there is a possibility to apply the process/
>>> batch/macro
>>> function to all open images or only a selection of images within  
>>> a folder?
>>> To batch process all images of a folder is somewhat inconvenient  
>>> for me.
>>>
>>> cheers,
>>> Finn
>>>
>>