Class AlgorithmAddMargins

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

public class AlgorithmAddMargins extends AlgorithmBase
Algorithm to add or remove margins around the image. Margins are defined in the screen-space coordinates. marginX is screen-space left,right. marginY is screen-space top,bottom. marginZ is screen-space front,back. Margins may be positive to add to the image, or negative to crop the image.
  • Field Details

    • marginX

      private int[] marginX
      marginX indicating the number of pixels to be padded on left and the right of X dimension
    • marginY

      private int[] marginY
      marginY indicating the number of pixels to be padded on top and the bottom of Y dimension
    • marginZ

      private int[] marginZ
      marginZ indicating the number of slices to be padded in front and the back of Z dimension
    • marginT

      private int[] marginT
      marginT indicating the number of slices to be padded in time at the start and end of T dimension
    • marginColor

      private double[] marginColor
  • Constructor Details

    • AlgorithmAddMargins

      public AlgorithmAddMargins(ModelImage srcImage, ModelImage destImage, int[] x, int[] y, int[] z)
      Add or remove margins from the srcImage and store the results in the destImage.
      Parameters:
      srcImage - original image
      destImage - output modified image
      x - margin in the screen-space x-direction to add or remove [left,right]
      y - margin in the screen-space y-direction to add or remove [top,bottom]
      z - margin in the screen-space z-direction to add or remove [front,back]
    • AlgorithmAddMargins

      public AlgorithmAddMargins(ModelImage srcImage, int[] x, int[] y, int[] z)
      Add or remove margins from the srcImage.
      Parameters:
      srcImage - original image modified by this algorithm.
      x - margin in the screen-space x-direction to add or remove [left,right]
      y - margin in the screen-space y-direction to add or remove [top,bottom]
      z - margin in the screen-space z-direction to add or remove [front,back]
  • Method Details

    • finalize

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

      public ModelImage getSrcImage()
      Returns the source image.
      Overrides:
      getSrcImage in class AlgorithmBase
      Returns:
      source image, may be modified.
    • runAlgorithm

      public void runAlgorithm()
      Runs the add image margins algorithm.
      Specified by:
      runAlgorithm in class AlgorithmBase
    • setPadValue

      public void setPadValue(float[] value)
      Sets the value for the added margins, for either grayscale or color images.
      Parameters:
      value - the image values to fill in the added margins.
    • setTMargins

      public void setTMargins(int[] tMargin)
      Adds or removes margins in the 4th dimensions.
      Parameters:
      tMargin - margins in time to add or remove from the image.
    • calcStoreInDest

      private void calcStoreInDest()
      Adds image margins and stores result in destImage.
    • calcStoreInPlace

      private void calcStoreInPlace()
      Adds image margins and stores result in srcImage Must use getSrcImage after running this routine.
    • updateFileInfo

      private void updateFileInfo(ModelImage kRead, ModelImage kWrite)
      Updates the fileInfo values for the kWrite image, uses the fileInfo values from kRead.
      Parameters:
      kRead - image to read fileInfo values from
      kWrite - image to write fileInfo values to.
    • calculateNewOrigin

      private float[] calculateNewOrigin(ModelImage srcImg, int[] margin)
      Calculates the origin values for the modified image, based on the current origin values and the added margins.
      Parameters:
      srcImg - original image
      margin - margins added or removed from the image
      Returns:
      new origins.