Login  Register

Re: batch processing imagecalculation add

Posted by HB on Feb 27, 2008; 7:48pm
URL: http://imagej.273.s1.nabble.com/batch-processing-imagecalculation-add-tp3697049p3697051.html

Hi Fernando,

Thanks a lot for your suggestion. I actually came up with a solution in the mean time which is a bit different:

macro "Batch Measure" {
    dir = getDirectory("Choose a Directory ");
    list = getFileList(dir);
        count=1;
      setBatchMode(true);
      for (i=0; i<list.length; i+=2) {
       
        path = dir+list[i];
        showProgress(i, list.length);
        if (!endsWith(path,"/")) open(path);
        if (nImages>=1) {
        open (dir+list[i]);
        rename ("A");
        open (dir+list[i+1]);
        rename ("B");
        imageCalculator("Add create", "A","B");
//run("Image Calculator...", "image1=A operation=Add image2=B create");

saveAs("BMP", "C:\\Documents and Settings\\Result"+count+".bmp");
       
        count++;
close();



};
            close();
       
    }
}


Anyway, your solution looks nice and I might be using it for other applications (i am working a lot with stacks).

Thanks again,

Herwig  


Fernando Sales wrote
Hi Herwig!

If i understood your problem, this should be solved with a simple plugin
using stacks. Using the command Open -> Import -> Image Sequence a stack
with all your images will be created.
If the images are in the correct order, you'll not have problems to process
them.
Just make a loop and call imageCalculation inside this.

Try something like this:
public class Test_ implements PlugIn {
  ImagePlus imps;

  public void run(String args) {
    IJ.run("Image Sequence..."); // Open Sequence and make stack

    // Load Stack
    this.imps = ij.WindowManager.getCurrentImage();
    ImageStack stack = imps.getImageStack();

    for (int k = 0; k < stack.getSize()-1; k++) {
      ImagePlus imp1 = new ImagePlus("Name ", stack.getProcessor(k + 1));
      ImagePlus imp2 = new ImagePlus("Name ", stack.getProcessor(k + 2));
     <Input your operations here...>
   }
...
}
}

You can find hints and examples in the tutorial available in:
http://www.imagingbook.com/index.php?id=102
I hope this can be helpful.

Good luck!
Fernando

On Sat, Feb 23, 2008 at 3:59 AM, herwig <bachmannherwig@hotmail.com> wrote:

> Hi there,
>
> I am pretty new to ImageJ and not good at writing macros.
> I've got 200 images in a folder and would like to add always two
> subsequent
> fotos up.
> Imagecalculation and the add function seem to be suitable for it.
> I've tried to write a little macro which loops through my files (they end
> with an increasing number) but I couldn't work it out so far.
> I couldn't find a solution in the forum either.
>
> I would be greatful for any  suggestion.
>
> cheers,
>
> herwig
> --
> View this message in context:
> http://www.nabble.com/batch-processing-imagecalculation-add-tp15641464p15641464.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>



--
**************************************************
Fernando José Ribeiro Sales
**************************************************
Email: fernando.sales@gmail.com
Tel: (11) 82020303
**************************************************