Class ImageCalculator

java.lang.Object
inra.ijpb.math.ImageCalculator

public class ImageCalculator
extends java.lang.Object
Provides some methods for combining two images, in a more comprehensive way than standard ImageJ, and providing the possibility of defining its own local operation. Example of use:

        int width = 255;
        int height = 255;
        ImageProcessor image1 = new ByteProcessor(width, height);
        ImageProcessor image2 = new ByteProcessor(width, height);
        for (int i = 0; i < width; i++)
        {
            for (int j = 0; j < height; j++)
            {
                image1.set(i, j, i);
                image2.set(j, i, i);
            }
        }
        
        ImageCalculator.Operation op = ImageCalculator.Operation.MAX;
        ImageProcessor result = ImageCalculator.combineImages(image1, image2, op);
        
        new ImagePlus("result", result).show();
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static interface  ImageCalculator.Operation
    General interface for defining an operation that combines the values of two pixels to create a new one.
  • Constructor Summary

    Constructors
    Constructor Description
    ImageCalculator()  
  • Method Summary

    Modifier and Type Method Description
    static ij.ImagePlus combineImages​(ij.ImagePlus image1, ij.ImagePlus image2, ImageCalculator.Operation op)
    Combines two images using the specified operation.
    static ij.ImageStack combineImages​(ij.ImageStack image1, ij.ImageStack image2, ImageCalculator.Operation op)
    Combines two images using the specified operation.
    static ij.process.ImageProcessor combineImages​(ij.process.ImageProcessor image1, ij.process.ImageProcessor image2, ImageCalculator.Operation op)
    Example that computes the maximum over two images:
    static ij.ImagePlus not​(ij.ImagePlus image)
    Computes the binary "not" operation on the input image.
    static ij.ImageStack not​(ij.ImageStack image)
    Computes the binary "not" operation on the input 3D image.
    static ij.process.ImageProcessor not​(ij.process.ImageProcessor image)
    Computes the binary "not" operation on the input 2D image.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ImageCalculator

      public ImageCalculator()
  • Method Details

    • combineImages

      public static final ij.ImagePlus combineImages​(ij.ImagePlus image1, ij.ImagePlus image2, ImageCalculator.Operation op)
      Combines two images using the specified operation.
      Parameters:
      image1 - the first image
      image2 - the second image
      op - the operation to apply
      Returns:
      the result of the combination of the two images.
    • combineImages

      public static final ij.process.ImageProcessor combineImages​(ij.process.ImageProcessor image1, ij.process.ImageProcessor image2, ImageCalculator.Operation op)
      Example that computes the maximum over two images:
       
       ImageProcessor image1 = ...
       ImageProcessor image2 = ...
       ImageProcessor result = ImageCalculator.combineImages(
                      image1, image2, ImageCalculator.Operation.MAX);  
       
       
      Parameters:
      image1 - the first input image
      image2 - the second input image
      op - the operation to apply
      Returns:
      the result of operation applied to the pair of input images
    • combineImages

      public static final ij.ImageStack combineImages​(ij.ImageStack image1, ij.ImageStack image2, ImageCalculator.Operation op)
      Combines two images using the specified operation.
      Parameters:
      image1 - the first image
      image2 - the second image
      op - the operation to apply
      Returns:
      the result of the combination of the two images.
    • not

      public static final ij.ImagePlus not​(ij.ImagePlus image)
      Computes the binary "not" operation on the input image.
      Parameters:
      image - the input image
      Returns:
      the result of the not operation
    • not

      public static final ij.process.ImageProcessor not​(ij.process.ImageProcessor image)
      Computes the binary "not" operation on the input 2D image.
      Parameters:
      image - the input image
      Returns:
      the result of the not operation
    • not

      public static final ij.ImageStack not​(ij.ImageStack image)
      Computes the binary "not" operation on the input 3D image.
      Parameters:
      image - the input image
      Returns:
      the result of the not operation