Module ij
Package ij.plugin

Class ImageCalculator

  • All Implemented Interfaces:
    PlugIn

    public class ImageCalculator
    extends Object
    implements PlugIn
    This plugin implements the Process/Image Calculator command.
       // test script
       imp1 = IJ.openImage("http://imagej.nih.gov/ij/images/boats.gif")
       imp2 = IJ.openImage("http://imagej.nih.gov/ij/images/bridge.gif")
       imp3 = ImageCalculator.run(imp1, imp2, "add create 32-bit");
       imp3.show();
    
    • Constructor Detail

      • ImageCalculator

        public ImageCalculator()
    • Method Detail

      • run

        public void run​(String arg)
        Description copied from interface: PlugIn
        This method is called when the plugin is loaded. 'arg', which may be blank, is the argument specified for this plugin in IJ_Props.txt.
        Specified by:
        run in interface PlugIn
      • run

        public static ImagePlus run​(ImagePlus img1,
                                    ImagePlus img2,
                                    String operation)
        Performs arithmetic options on two images and returns the result, where 'operation' ("add","subtract", "multiply","divide", "and", "or", "xor", "min", "max", "average", "difference" or "copy") specifies the operation. If 'operation' does not contain 'create' or '32-bit', the result is also saved in 'imp1" and null is returned if "imp1" is displayed. The 'operation' argument can include up to three modifiers: "create" (e.g., "add create") causes the result to be returned as a new image, "32-bit" causes the result to be returned as 32-bit floating-point image and "stack" causes the entire stack to be processed. As an example,
                        imp3 = ImageCalculator.run(imp1, imp2, "divide create 32-bit");
                        
        divides 'imp1' by 'imp2' and returns the result as a new 32-bit image.
      • calculate

        public void calculate​(String operation,
                              ImagePlus img1,
                              ImagePlus img2)
        Deprecated.
        replaced by run(String,ImagePlus,ImagePlus)