Class AlgorithmLevelSetDiffusion

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

    public class AlgorithmLevelSetDiffusion
    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)

    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

    • Field Detail

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

        private boolean image25D
        If true in 3D images, process each slice separately
      • outputBuffer

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

      • AlgorithmLevelSetDiffusion

        public AlgorithmLevelSetDiffusion​(ModelImage srcImg,
                                          float[] sigmas,
                                          int iter,
                                          float kValue,
                                          boolean image25D)
        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;
        image25D - If true in 3D images, process each slice separately
    • 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.
      • calc25D

        private void calc25D()
        calc25D - calculates the diffused image and creates the new VOI for the original image. In a 3D image processes each slice separately
      • 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