how to call image calculator in a plugin

Posted by jvander on
URL: http://imagej.273.s1.nabble.com/how-to-call-image-calculator-in-a-plugin-tp5001766.html

I am not a java programmer but I am using the plugins -> macro -> record approach to creating and compiling plugins.  I have used this approach successfully in the past for various functions.  I am having trouble calling the image calculator. I have reduced the program to just calling image calculator and multiplying two existing images together.  Below is the java that is generated followed by the error.  My guess is that I need to specify a type for ic when it is introduced in the code below.  Can someone give me a tip to get past this hurdle?  Thanks

Joe v.

here is the java that is generated by compile and run

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

public class image_calc_only implements PlugIn {

        public void run(String arg) {
                ImagePlus imp1 = IJ.getImage();
               ImagePlus imp2 = IJ.getImage();
                ImagePlus imp3 = IJ.getImage();
                ic = new ImageCalculator();
                imp3 = ic.run("Multiply create 32-bit", imp1, imp2);
        }

}

Here are the errors.    

/Applications/ImageJ/plugins/myplugins/image_calc_only.java:14: cannot find symbol
symbol  : variable ic
location: class image_calc_only
                ic = new ImageCalculator();
                ^
/Applications/ImageJ/plugins/myplugins/image_calc_only.java:15: cannot find symbol
symbol  : variable ic
location: class image_calc_only
                imp3 = ic.run("Multiply create 32-bit", imp1, imp2);
                       ^
2 errors

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