Class AlgorithmCoherenceEnhancingDiffusion

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

    public class AlgorithmCoherenceEnhancingDiffusion
    extends AlgorithmBase

    Algorithm to apply Coherence Enhancing Anisotropic Diffusion

    For color form a common structure tensor for all colors by averaging the structure tensors for each color.

    References:

    1. Joachim Weickert
      Chapter 15 Nonlinear Diffusion Filtering in Handbook of Computer Vision and Applications, Volume 2 Signal Processing and Pattern Recognition. The book is published by Academic Press, ISBN 0-12-379772-1
    2. Algorithms for Non-Linear Diffusion Matlab in a Literate Programming Style by Rein van den Boomgaard, Intelligent Sensory Information Systems, University of Amsterdam, The Netherlands http://carol.wins.uva.nl/~rein/nldiffusionweb/material.html
    3. Coherence-Enhancing Diffusion of Colour Images by Joachim Weickert, A. Sanfeliu, J.J. Villanueva, J. Vitria, editors, Proc. VII National Symposium on Pattern Recognition and Image Analysis (VII NSPRIA, Barcelona, April 21-25, 1997), Vol. 1, pp. 239-244, 1997.
    4. Coherence-Enhancing Diffusion of Colour Images by Joachim Weickert, Image and Vision Computing, Vol. 17, 1999, pp. 201-212.
    5. Coherence-Enhancing Diffusion Filtering by Joachim Weickert, International Journal of Computer Vision, Vol. 31, No. 2/3, pp. 111-127, April, 1999
    Version:
    1.0; 31, July 2003
    Author:
    Paul F. Hemler, Ph.D.
    • Field Detail

      • derivativeScale

        float derivativeScale
        Gaussian scale for derivative operations.
      • do25D

        boolean do25D
        flag indicating 2.5D processing.
      • gaussianScale

        float gaussianScale
        Gaussian scale for structure tensor smoothing.
      • k

        double k
        diffusitivity denominator.
      • k2

        double k2
        diffusitivity denominator squared.
      • numIterations

        int numIterations
        The number of iterations.
      • timeStep

        float timeStep
        The time parameter step size, called tau in the algorithm description In 2D for stability the time step should be
        • dxKernelX

          private float[] dxKernelX
          Kernels for the X derivative.
        • dxKernelY

          private float[] dxKernelY
          DOCUMENT ME!
        • dxKernelZ

          private float[] dxKernelZ
          DOCUMENT ME!
        • dyKernelX

          private float[] dyKernelX
          Kernels for the Y derivative.
        • dyKernelY

          private float[] dyKernelY
          DOCUMENT ME!
        • dyKernelZ

          private float[] dyKernelZ
          DOCUMENT ME!
        • dzKernelX

          private float[] dzKernelX
          Kernels for the Z derivative.
        • dzKernelY

          private float[] dzKernelY
          DOCUMENT ME!
        • dzKernelZ

          private float[] dzKernelZ
          DOCUMENT ME!
        • eigenSystemAlgo

          private WildMagic.LibFoundation.NumericalAnalysis.Eigenf eigenSystemAlgo
          Eigensystem solver.
        • entireImage

          private boolean entireImage
          Whether to process the entire image, or just the portion within the currently selected VOI.
        • intermediateBuffer

          private float[] intermediateBuffer
          Reference to intermediate buffer.
        • kRadius

          private int kRadius
          Width of the derivative buffer.
        • skernelX

          private float[] skernelX
          Kernels for the Smoothing kernel.
        • skernelY

          private float[] skernelY
          DOCUMENT ME!
        • skernelZ

          private float[] skernelZ
          DOCUMENT ME!
        • skRadius

          private int skRadius
          Width of the smoothing buffer.
        • xDim

          private int xDim
          image dimensions.
        • yDim

          private int yDim
          image dimensions.
        • zDim

          private int zDim
          image dimensions.
        • Constructor Detail

          • AlgorithmCoherenceEnhancingDiffusion

            public AlgorithmCoherenceEnhancingDiffusion​(ModelImage srcImg,
                                                        int numI,
                                                        float k,
                                                        float derivativeScale,
                                                        float gaussianScale,
                                                        boolean do25D,
                                                        boolean entireImage)
            Creates a new AlgorithmCoherenceEnhancingDiffusion object.
            Parameters:
            srcImg - Source image model
            numI - Number of iterations
            k - Diffusitivity denominator
            derivativeScale - Scale of the gaussian when taking derivatives
            gaussianScale - Scale of the gaussian for smoothing the structure tensor
            do25D - Flag indicating 2.5D processing
            entireImage - whether to filter the entire image or just the VOI region
          • AlgorithmCoherenceEnhancingDiffusion

            public AlgorithmCoherenceEnhancingDiffusion​(ModelImage destImg,
                                                        ModelImage srcImg,
                                                        int numI,
                                                        float k,
                                                        float derivativeScale,
                                                        float gaussianScale,
                                                        boolean do25D,
                                                        boolean entireImage)
            Creates a new AlgorithmCoherenceEnhancingDiffusion object.
            Parameters:
            destImg - Image model where result image is to stored
            srcImg - Source image model
            numI - Number of iterations
            k - Diffusitivity denominator
            derivativeScale - Scale of the gaussian when taking derivatives
            gaussianScale - Scale of the gaussian for smoothing the structure tensor
            do25D - Flag indicating 2.5D processing
            entireImage - whether to filter the entire image or just the VOI region
        • Method Detail

          • finalize

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

            private static float max​(float a,
                                     float b)
            Computes the maximum of two floating point numbers passed in.
            Parameters:
            a - float The first value
            b - float The second value
            Returns:
            float The maximum of values a and b
          • computeDx

            private void computeDx​(float[] dx,
                                   float[] src)
            DOCUMENT ME!
            Parameters:
            dx - float [] destination buffer
            src - float [] source buffer

            Member function computes the derivative of the source buffer in the X-direction using the kernel formulation as specified in the MATLAB paper. The function uses seperable convolution, which means it first does a 1D convolution with the derivative of a Gaussian kernel in the X-direction and stores the result in an intermediate buffer. Once the intermediate buffer is completely filled, a smoothing in the Y-direction is performed using a 1D Gaussian kernel computed as in the MATLAB paper.

          • computeDx3D

            private void computeDx3D​(float[] dx,
                                     float[] src)
            DOCUMENT ME!
            Parameters:
            dx - float [] destination buffer
            src - float [] source buffer

            Member function computes the derivative of the source buffer in the X-direction using the kernel formulation as specified in the MATLAB paper. The function uses seperable convolution, which means it first does a 1D convolution with the derivative of a Gaussian kernel in the X-direction and stores the result in dx buffer. Once dx is completely filled, a smoothing in the Y-direction is performed using a 1D Gaussian kernel and the intermediate result is stored in intermediateBuffer. Once intermediateBuffer is completely filled, a smoothing in the Z-direction is performed and the final result is placed in dx.

          • computeDy

            private void computeDy​(float[] dy,
                                   float[] src)
            DOCUMENT ME!
            Parameters:
            dy - float [] destination buffer
            src - float [] source buffer

            Member function computes the derivative of the source buffer in the Y-direction using the kernel formulation as specified in the MATLAB paper. The function uses seperable convolution, which means it first does a 1D convolution with a Gaussian kernel in the X-direction and stores the result in an intermediate buffer. Once the intermediate buffer is completely filled, a 1D convolution in the Y-direction is performed using a 1D Gaussian derivative kernel computed as in the MATLAB paper.

          • computeDy3D

            private void computeDy3D​(float[] dy,
                                     float[] src)
            DOCUMENT ME!
            Parameters:
            dy - float [] destination buffer
            src - float [] source buffer

            Member function computes the derivative of the source buffer in the Y-direction using the kernel formulation as specified in the MATLAB paper. The function uses seperable convolution, which means it first does a 1D smoothing convolution with a Gaussian kernel in the X-direction and stores the result in dy buffer. Once dy is completely filled, a convolution in the Y-direction is performed using the derivative of a 1D Gaussian kernel and the intermediate result is stored in intermediateBuffer. Once intermediateBuffer is completely filled, a smoothing in the Z-direction is performed and the final result is placed in dy.

          • computeDz

            private void computeDz​(float[] dz,
                                   float[] src)
            DOCUMENT ME!
            Parameters:
            dz - float [] destination buffer
            src - float [] source buffer

            Member function computes the derivative of the source buffer in the Z-direction using the kernel formulation as specified in the MATLAB paper. The function uses seperable convolution, which means it first does a 1D convolution with a Gaussian kernel in the X-direction and stores the result in dz buffer. Once dz is completely filled, a smoothing in the Y-direction is performed using a 1D Gaussian kernel and the intermediate result is stored in intermediateBuffer. Once intermediateBuffer is completely filled, a convolution with the derivative of a Gaussian kernel in the Z-direction is performed and the final result is placed in dz.

          • gaussianSmooth

            private void gaussianSmooth​(float[] gs,
                                        float[] src)
            DOCUMENT ME!
            Parameters:
            gs - float [] destination buffer
            src - float [] source buffer

            Member function gaussian smoothes the source buffer in the x and y directions using the kernel formulation as specified in the MATLAB paper. The function uses seperable convolution, which means it first does a 1D convolution with a Gaussian kernel in the X-direction and stores the result in an intermediate buffer. Once the intermediate buffer is completely filled, a 1D convolution in the Y-direction is performed using a 1D Gaussian kernel.

          • gaussianSmooth3D

            private void gaussianSmooth3D​(float[] gs,
                                          float[] src)
            DOCUMENT ME!
            Parameters:
            gs - float [] destination buffer
            src - float [] source buffer

            Member function gaussian smoothes the source buffer in the x,y, and z directions using the kernel formulation as specified in the MATLAB paper. The function uses seperable convolution, which means it first does a 1D convolution with a Gaussian kernel in the X-direction and stores the result in gs. Once the gs buffer is completely filled, a 1D convolution in the Y-direction is performed using a 1D Gaussian kernel and the result is stored in intermediateBuffer. Once intermediateBuffer is completely filled, a 1D convolution in the Z-direction is performed using a 1D Gaussian kernel and the result is placed in gs.

          • getVal

            private float getVal​(float[] buffer,
                                 int col,
                                 int row)
            Returns the value in a 2D image buffer of the pixel at location row, col.
            Parameters:
            buffer - float[] The image buffer
            col - int Column index
            row - int Row index
            Returns:
            float The pixel value
          • getVal

            private float getVal​(float[] buffer,
                                 int col,
                                 int row,
                                 int slice)
            Returns the value in a 3D image buffer of the pixel at location slice, row, col.
            Parameters:
            buffer - float[] The image buffer
            col - int Column index
            row - int Row index
            slice - int Slice index
            Returns:
            float The pixel value
          • init

            private void init()
            Initialize buffers and kernels.
          • run2D

            private void run2D​(int numImages)
            Starts the algorithm for 2D images.
            Parameters:
            numImages - int The number of 2D images
          • run2DC

            private void run2DC​(int numImages)
            Starts the algorithm for 2D images.
            Parameters:
            numImages - int The number of 2D images
          • run3D

            private void run3D()
            Starts the algorithm for 3D images.
          • run3DC

            private void run3DC()
            Starts the algorithm for 3D color images.
          • setVal

            private void setVal​(float val,
                                float[] buffer,
                                int col,
                                int row)
            Sets the value in a 2D image buffer at location row, col.
            Parameters:
            val - float The value to set the pixel to
            buffer - float[] 2D image buffer
            col - int Column index
            row - int Row index
          • setVal

            private void setVal​(float val,
                                float[] buffer,
                                int col,
                                int row,
                                int slice)
            Sets the value in a 3D image buffer at location row, col.
            Parameters:
            val - float The value to set the pixel to
            buffer - float[] 3D image buffer
            col - int Column index
            row - int Row index
            slice - int Slice index