Class AlgorithmVOISimplexOpt

  • All Implemented Interfaces:
    de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables, java.awt.event.ActionListener, java.awt.event.WindowListener, java.lang.Runnable, java.util.EventListener

    public class AlgorithmVOISimplexOpt
    extends AlgorithmBase
    implements de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
    Perform Simplex Optimization on a VOI that has been propagated to a slice to find a transformation which will make an affine "fit" a structure which the VOI fit on the previous slice (used in RFASegTool when propagating liver segmentation VOIs). Minimize cost = -sum of Gradient magnitude under propagated ROI in match image
    Version:
    1.0 July, 2003
    Author:
    Evan McCreedy
    • Field Detail

      • MINDIFF

        public static final int MINDIFF
        Indicates that the minimum difference cost function should be used (MAXSUM is perferred).
        See Also:
        Constant Field Values
      • MAXSUM

        public static final int MAXSUM
        Indicates that the maximum summation cost function should be used (this is the perferred cost function).
        See Also:
        Constant Field Values
      • baseVOIGradMagSum

        protected float baseVOIGradMagSum
        The sum of the gradient magnitude along the polygon.
      • costFunc

        protected int costFunc
        Which cost function to use (MINDIFF or MAXSUM).
      • currentSlice

        private int currentSlice
        The slice number the VOI is in.
      • gradMagBuf

        protected float[] gradMagBuf
        The gradient magnitude of the slice.
      • image

        private ModelImage image
        The source image.
      • inputGon

        protected VOIContour inputGon
        The polygon of the VOI we are fitting.
      • sigmas

        private float[] sigmas
        the kernel size to use in calculating the gradient magnitude image.
      • simplexDim

        private int simplexDim
        Size of the simplex vertex array (5 == tx, ty, rot, zoomx, zoomy).
      • sliceBuf

        private float[] sliceBuf
        The image slice that holds the VOI we are working on.
      • xDim

        protected int xDim
        The slice size in the x dimension.
      • yDim

        protected int yDim
        The slice size in the y dimension.
    • Constructor Detail

      • AlgorithmVOISimplexOpt

        public AlgorithmVOISimplexOpt​(ModelImage image,
                                      float[] sigmas,
                                      int costFunc)
        Set up the algorithm to perform optimizations on an image. The individual Polygons to optimize will be provided later (use goOptimize())
        Parameters:
        image - the image containing the VOI(s) to run the SimplexOpt algorithm on
        sigmas - the kernel size to use in calculating the gradient magnitude image
        costFunc - which cost function to use (MINDIFF or MAXSUM)
      • AlgorithmVOISimplexOpt

        public AlgorithmVOISimplexOpt​(ModelImage image,
                                      VOIContour inputGon,
                                      float[] sigmas,
                                      int costFunc)
        Set up the algorithm to perform optimizations on an image. To be used in conjunction with the run method.
        Parameters:
        image - the image containing the VOI(s) to run the SimplexOpt algorithm on
        inputGon - the Polygon to optimize the fit of
        sigmas - the kernel size to use in calculating the gradient magnitude image
        costFunc - which cost function to use (MINDIFF or MAXSUM)
    • Method Detail

      • finalize

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

        public VOIContour goOptimize​(float[] sliceBuf,
                                     VOIContour inputGon)
        Run the simplex opt algorithm on a polygon (VOI) in a slice of an image.
        Parameters:
        sliceBuf - the slice the polygon resides in
        inputGon - the polygon to optimize the fit of
        Returns:
        the optimized polygon
      • runAlgorithm

        public void runAlgorithm()
        Run the algorithm on a polygon already specified through the constructor.
        Specified by:
        runAlgorithm in class AlgorithmBase
      • setCurrentSlice

        public void setCurrentSlice​(int currentSlice)
        Specify the slice containing the VOI to optimize.
        Parameters:
        currentSlice - the slice with the VOI to optimize
      • setPolygon

        public void setPolygon​(VOIContour poly)
        Spefify the VOI polygon to optimize.
        Parameters:
        poly - the polygon
      • getTransform

        protected TransMatrix getTransform​(double[] x)
        Converts a row of p into 3x3 transformation matrix.
        Parameters:
        x - row of p[][] (one of the simplex vertices)
        Returns:
        the transformation matrix corresponding to x
      • search

        private VOIContour search()
        Find the best fit for the VOI polygon we have loaded into this algorithm.
        Returns:
        the optimized polygon
      • eval

        public double eval​(double[] x)
        Specified by:
        eval in interface de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
      • getNumberOfVariables

        public int getNumberOfVariables()
        Specified by:
        getNumberOfVariables in interface de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables