Class AlgorithmImageMath

java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.utilities.AlgorithmImageMath
All Implemented Interfaces:
ActionListener, WindowListener, Runnable, EventListener

public class AlgorithmImageMath extends AlgorithmBase
Algorithm that adds, subtracts, multiplies, or divides an image by some user specified value. In addition, the square root or log of an image can be calculated. If the new image exceeds the range that can be stored in an image of that type the data is either clipped and stored in the original image. Or a new image of a type (int, float...) that can store the range of new data is generated.
Version:
1.0 Dec 30, 1999
Author:
Matthew J. McAuliffe, Ph.D.
  • Field Details

    • ABSOLUTE_VALUE

      public static final int ABSOLUTE_VALUE
      DOCUMENT ME!
      See Also:
    • ADD

      public static final int ADD
      DOCUMENT ME!
      See Also:
    • AVERAGE

      public static final int AVERAGE
      DOCUMENT ME!
      See Also:
    • CONSTANT

      public static final int CONSTANT
      DOCUMENT ME!
      See Also:
    • DIVIDE

      public static final int DIVIDE
      DOCUMENT ME!
      See Also:
    • LOG

      public static final int LOG
      DOCUMENT ME!
      See Also:
    • MULTIPLY

      public static final int MULTIPLY
      DOCUMENT ME!
      See Also:
    • SQUARE

      public static final int SQUARE
      DOCUMENT ME!
      See Also:
    • SQUARE_ROOT

      public static final int SQUARE_ROOT
      DOCUMENT ME!
      See Also:
    • SUBTRACT

      public static final int SUBTRACT
      DOCUMENT ME!
      See Also:
    • SUM

      public static final int SUM
      DOCUMENT ME!
      See Also:
    • INVERSE

      public static final int INVERSE
      DOCUMENT ME!
      See Also:
    • EXP

      public static final int EXP
      See Also:
    • CLIP

      public static final int CLIP
      DOCUMENT ME!
      See Also:
    • PROMOTE

      public static final int PROMOTE
      DOCUMENT ME!
      See Also:
    • CONVERT_FLOAT

      public static final int CONVERT_FLOAT
      DOCUMENT ME!
      See Also:
    • clipMax

      private double clipMax
      Maximum clipping modes if data result value exceeds the capacity of image's data type.
    • clipMin

      private double clipMin
      Minimum clipping modes if data result value exceeds the capacity of image's data type.
    • clipMode

      private int clipMode
      Clipping mode.
                                CLIP          = 0;   clamp result data to the bounds of the input image type
                                PROMOTE       = 1;   promote image type so that the range of the result fits into
                                                     the new image type. ( ie. byte to short).
                                FLOAT         = 2;   Convert image to float                     
                         
    • entireImage

      private boolean entireImage
      Flag, if true, indicates that the whole image should be processed. If false, process the image over the mask areas.
    • max

      private double max
      Used to store the image maximum.
    • min

      private double min
      Used to store the image minimum.
    • minR

      private double minR
    • maxR

      private double maxR
    • minG

      private double minG
    • maxG

      private double maxG
    • minB

      private double minB
    • maxB

      private double maxB
    • opType

      Operation to be performed on the images (i.e. Add, ...)
    • useComplex

      private boolean useComplex
      DOCUMENT ME!
    • value

      private double value
      the value to modify the image with.
    • valueI

      private double valueI
      imaginary part of value to modify complex or dcomplex image with or green color of color image.
    • valueB

      private double valueB
  • Constructor Details

    • AlgorithmImageMath

      public AlgorithmImageMath(ModelImage srcImg, int type, double val, double valI, double valB, int _clipMode, boolean maskFlag)
      Creates a new AlgorithmImageMath object.
      Parameters:
      srcImg - source image model
      type - operation type to be performed on the image
      val - value applied to the image
      valI - imaginary part of value applied if image is of complex type or green part of color if color image
      valB - blue part of color image
      _clipMode - clamp data to image type range or promote image type to hold new data range.
      maskFlag - Flag that indicates that the operator will be calculated for the whole image if equal to true
    • AlgorithmImageMath

      public AlgorithmImageMath(ModelImage destImg, ModelImage srcImg, int type, double val, double valI, double valB, int _clipMode, boolean maskFlag)
      Creates a new AlgorithmImageMath object.
      Parameters:
      destImg - image model where result image is to stored
      srcImg - source image model
      type - operation type to be performed on the image
      val - value applied to the image
      valI - imaginary part of value applied if image is of complex type or green part of color if color image
      valB - blue part of color image
      _clipMode - clamp data to image type range or promote image type to hold new data range.
      maskFlag - Flag that indicates that the operator will be calculated for the whole image if equal to true
  • Method Details

    • finalize

      public void finalize()
      Prepares this class for destruction.
      Overrides:
      finalize in class AlgorithmBase
    • runAlgorithm

      public void runAlgorithm()
      Starts the program.
      Specified by:
      runAlgorithm in class AlgorithmBase
    • calcInPlaceColor

      private void calcInPlaceColor()
    • calcInPlace

      private void calcInPlace()
      Generates the new data and places in the source image.

      note that if this method is canceled part-way through a multi-sliced image, it will almost certainly be partially adjusted. This is because to save memory buffer-space, it returns an adjusted slice back to the source image after processing it; it then takes out the next slice to alter it. Canceling a job causes the current slice will not be affected, but all previous slices will be.

    • calcInPlaceComplex

      private void calcInPlaceComplex()
      Generates the new data and places in the source image.

      note that if this method is canceled part-way through a multi-sliced image, it will almost certainly be partially adjusted. This is because to save memory buffer-space, it returns an adjusted slice back to the source image after processing it; it then takes out the next slice to alter it. Canceling a job causes the current slice will not be affected, but all previous slices will be.

    • calcStoreInDestColor

      private void calcStoreInDestColor()
    • calcStoreInDest

      private void calcStoreInDest()
      Generates the new data and places in a new (destination) image.

      This method checks for thread halting actions more infrequently than the in-place method.

    • calcStoreInDestComplex

      private void calcStoreInDestComplex()
      Generates the new data and places in a new (destination) image.
    • findType

      private int findType(int stType)
      Find the type able to contain the full range of the data.
      Parameters:
      stType - starting type of image. Image will be promoted above this type if needed.
      Returns:
      type capable of storing full range of data. See ModelStorageBase for image types.
    • promoteType

      private int promoteType(int presentType)
      DOCUMENT ME!
      Parameters:
      presentType - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • setClipValues

      private void setClipValues()
      Sets clipMin and clipMax.
    • testType

      private boolean testType(int type, double minVal, double maxVal)
      Determine if the min and max values are in the image types range.
      Parameters:
      type - image type
      minVal - min value of the image
      maxVal - max value of the image
      Returns:
      true if min and max are within the image type specified