Class AlgorithmFastMarching

  • All Implemented Interfaces:
    AlgorithmInterface, java.awt.event.ActionListener, java.awt.event.WindowListener, java.lang.Runnable, java.util.EventListener

    public class AlgorithmFastMarching
    extends AlgorithmBase
    implements AlgorithmInterface
    DOCUMENT ME!
    Version:
    0.1 March 6, 1998
    Author:
    Matthew J. McAuliffe, Ph.D.

    This algorithm iteratively expands a contour to a boundary.

    This version of the anisotropic diffusion equation is: dI/dt = div[g(normalized grad magnitude(image))* grad I], where g() is the edge stopping function. The original edge stopping function used was the Perona and Malik function: g(x) = 1/(1 + (x**2/k**2)). However, as outlined in "Robust Anisotropic Diffusion" by Michael J. Black, Guillermo Sapiro, David H. Marimont, and David Heeger, IEEE Transactions on Image Processing, Vol. 7, No. 3, March 1998, pp. 421-432, the Perona and Malik function gives outliers(large values of grad(image)) too much influence. Thus, the Perona and Malik function was replaced with the Tukey's biweight function: g(x) = 0.5 * [1 - (x/k)**2]**2 for abs(x) <= k = 0 otherwise.

    The normalized gradient magnitude of the image goes from 0 to 100. In the above equation I is a VOI intensity, where initially all the VOI area is assigned 100 and the rest of the image is assigned 0. The equation is discretized as: I(x,y,z,t+1) = I(x,y,z,t) + 0.25*g(normalized grad magnitude(image(x,y,z)))* (I(x+gradX,y+gradY,z+gradZ,t) - I(x,y,z,t)), where gradX, gradY, and gradZ are the normalized gradient measurements of I. The value of I is clamped to a maximum value of 100 and the value of I is not changed if either its value has fallen to be <= 3 or the values of all 4 of its nearest neighbors are <= 3. Note that the name AlgorithmLevelSet is misleading because the equation used is a version of the anisotropic diffusion equation and not a version of the level set equation given by Osher and Sethian: d(phi)/dt + F*|grad(phi)| = 0, given phi(x,y,z,t=0). For more information on the Anisotropic diffusion equation see: Geometry-Driven Diffusion in Computer Vision edited by Bart M. ter Haar Romeny, Chapter 3 on Anisotropic Diffusion by Pietro Perona, Takahiro Shiota, and Jitendra Malik, pages 73-92, Kluwer Academic Publishers, 1994.

    • Field Detail

      • edgeImage

        private float[] edgeImage
        DOCUMENT ME!
      • GxData

        private float[] GxData
        Storage location of the first derivative of the Gaussian in the X direction.
      • GyData

        private float[] GyData
        Storage location of the first derivative of the Gaussian in the Y direction.
      • GzData

        private float[] GzData
        Storage location of the first derivative of the Gaussian in the Z direction.
      • iterations

        private int iterations
        Number of iterations of the diffusion.
      • kExtents

        private int[] kExtents
        Dimensionality of the kernel.
      • kValue

        private float kValue
        Controls the diffusion rate. A large value causes this algorithms to act like gaussian smoothing and therefore diffuses across edges. K = small reduces blur across edges. Typical K = 10.
      • levelImage

        private float[] levelImage
        DOCUMENT ME!
      • sigmas

        private float[] sigmas
        Standard deviations of the gaussian used to calculate the kernels.
      • outputBuffer

        private float[] outputBuffer
        Stores result of AlgorithmConvolver
    • Constructor Detail

      • AlgorithmFastMarching

        public AlgorithmFastMarching​(ModelImage srcImg,
                                     float[] sigmas,
                                     int iter,
                                     float kValue)
        AnisotropicDiffusion.
        Parameters:
        srcImg - reference to the source image
        sigmas - sigmas used to describe the gaussian that is used in the calculation of the gradient magnitude
        iter - number of iterations (t) of the diffusion equation
        kValue - K is a factor that controls the diffusion rate. A large value causes this algorithms to act like gaussian smoothing and therefore diffuses across edges. K = small reduces blur across edges. Typical K = 10;
    • Method Detail

      • cleanUp

        public void cleanUp()
        DOCUMENT ME!
      • finalize

        public void finalize()
        finalize - sets class storages arrays to null so that System.gc() can free the memory.
        Overrides:
        finalize in class AlgorithmBase
      • calc2D

        private void calc2D()
        calc2D - calculates the diffused image and creates the new VOI for the original image.
      • calc3D

        private void calc3D()
        calc3D - calculates the diffused image and creates the new VOI for the original image.
      • getBiLinear

        private float getBiLinear​(float[] imageBuffer,
                                  int xDim,
                                  float x,
                                  float y)
        getBiLinear - version of get that performs bi-linear interpoloation. Note - does NOT perform bounds checking
        Parameters:
        imageBuffer - buffer containing pixel data
        xDim - x dimension offset
        x - x coordinate
        y - y coordinate
        Returns:
        DOCUMENT ME!
      • getTriLinear

        private float getTriLinear​(float[] imageBuffer,
                                   int xDim,
                                   int imageSliceSize,
                                   float x,
                                   float y,
                                   float z)
        getTriLinear - version of get that performs trilinear interpoloation.
        Parameters:
        imageBuffer - buffer containing pixel data
        xDim - x dimension offset
        imageSliceSize - DOCUMENT ME!
        x - x coordinate
        y - y coordinate
        z - z coordinate
        Returns:
        DOCUMENT ME!
      • makeKernels2D

        private void makeKernels2D()
        makeKernals2D - creates the derivative kernels used to calculate the gradient magnitude and kernel for the diffusion process.
      • makeKernels3D

        private void makeKernels3D()
        makeKernals3D - creates the derivative kernels used to calculate the gradient magnitude and kernel for the diffusion process.
      • algorithmPerformed

        public void algorithmPerformed​(AlgorithmBase algorithm)
        Description copied from interface: AlgorithmInterface
        Called after an algorithm this listener is registered to exits (maybe successfully, maybe not). If the algorithm is run in a separate thread, this call will be made within that thread. If not, this call will be made from that same, shared thread.
        Specified by:
        algorithmPerformed in interface AlgorithmInterface
        Parameters:
        algorithm - the algorithm which has just completed