Class AlgorithmSubtractVOI

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

public class AlgorithmSubtractVOI extends AlgorithmBase
Algorithm that subtracts the mean or median value of a VOI from the image. If only 1 contour is present, that contour is used whether or not it is selected. If multiple contours are present, at least 1 contour must be selected, and only selected contours are used. Note that under MIPAV all selected contours must belong to the same VOI. 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. For color the dialog currently disables promotion for color because MIPAV cannot handle negative color values.
  • Field Details

    • MEAN

      public static final int MEAN
      DOCUMENT ME!
      See Also:
    • MEDIAN

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

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

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

      private double average
      DOCUMENT ME!
    • averageB

      private float averageB
      DOCUMENT ME!
    • averageG

      private float averageG
      DOCUMENT ME!
    • averageMode

      private int averageMode
      DOCUMENT ME!
    • averageR

      private float averageR
      DOCUMENT ME!
    • clipMax

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

      private float clipMaxC
      DOCUMENT ME!
    • clipMin

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

      private float clipMinC
      DOCUMENT ME!
    • 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).
                         
    • max

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

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

      private double minR
      DOCUMENT ME!
    • minG

      private double minG
      DOCUMENT ME!
    • minB

      private double minB
      DOCUMENT ME!
  • Constructor Details

    • AlgorithmSubtractVOI

      public AlgorithmSubtractVOI(ModelImage srcImg, int _averageMode, int _clipMode)
      Creates a new AlgorithmSubtractVOI object.
      Parameters:
      srcImg - source image model
      _averageMode - mean or median of VOI
      _clipMode - clamp data to image type range or promote image type to hold new data range.
    • AlgorithmSubtractVOI

      public AlgorithmSubtractVOI(ModelImage destImg, ModelImage srcImg, int _averageMode, int _clipMode)
      Creates a new AlgorithmSubtractVOI object.
      Parameters:
      destImg - image model where result image is to stored
      srcImg - source image model
      _averageMode - mean or median of VOI
      _clipMode - clamp data to image type range or promote image type to hold new data range.
  • 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
    • 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.

    • calcInPlaceColor

      private void calcInPlaceColor()
      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.

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

    • calcStoreInDestColor

      private void calcStoreInDestColor()
      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.

    • 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.
    • getAverage

      private void getAverage()
      DOCUMENT ME!
    • 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