Login  Register

Image calculator behaves differently in plug in

Posted by jvander on May 02, 2013; 4:49pm
URL: http://imagej.273.s1.nabble.com/Image-calculator-behaves-differently-in-plug-in-tp5002896.html

Image calculator behaves differently in plug in

I have some 8 bit images which happen to be binary valued, 0 and 255.  White is 255 and Black is zero.  When I use Image calculator from the menu I get expected results for all the operators including AND, Mult, OR , and Add.  

Right now I am trying to do the following
mask image called A with 1   result is image called A1
mask image called B with 2 result is image called B2
OR together A1 and B2

The first time I run the plug in the masking works and the OR gives unexpected results
The second time I run things the masking is inverted compared to the first run.

Clearly I have some bad syntax.  Help is appreciated.  Below is my code


import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
import ij.plugin.frame.*;

public class kinetic_combine_three implements PlugIn {

        public void run(String arg) {
                IJ.run("Image Calculator...", "image1=1 AND image2=A create");
                IJ.run("Rename...","title=A1");
                IJ.run("Image Calculator...", "image1=B AND image2=2 create");
                IJ.run("Rename...","title=B2");
                    IJ.run("Image Calculator...", "image1=A1 OR image2=B2 create");
                IJ.run("Rename...","title=A1B2");
     
        }

}

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