Class AlgorithmAddMargins

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

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

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

      • finalize

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