Class AlgorithmImageMath

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.WindowListener, java.lang.Runnable, java.util.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 Detail

      • 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
      • 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 Detail

      • 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 Detail

      • finalize

        public void finalize()
        Prepares this class for destruction.
        Overrides:
        finalize 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