Login  Register

batch processing imagecalculation add

Posted by HB on Feb 22, 2008; 8:23pm
URL: http://imagej.273.s1.nabble.com/batch-processing-imagecalculation-add-tp3697049.html

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.

Here is what I did so far


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

saveAs("BMP", "C:\\Documents and Settings\\Administrator\\Desktop\\list[i].bmp");
}

            close();
        }
    }

The macro seems to be doing something but it definitely doesn't save the result I would like to have.

I would be greatful for any  suggestion.

cheers,

herwig