Class AlgorithmGradientMagnitude

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

    public class AlgorithmGradientMagnitude
    extends AlgorithmBase
    implements AlgorithmInterface
    Calculates the gradient magnitude of an image at a scale defined by the user.
    Version:
    0.1 Feb 11, 1998
    Author:
    Matthew J. McAuliffe, Ph.D.
    • Field Detail

      • blue

        private boolean blue
        DOCUMENT ME!
      • entireImage

        private boolean entireImage
        Flag, if true, indicates that the whole image should be processed. If false only process the image over the mask areas.
      • green

        private boolean green
        DOCUMENT ME!
      • Gx2Data

        private float[] Gx2Data
        Storage location of the first derivative of the Gaussian in the X direction for 2D images;
      • GxData

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

        private float[] Gy2Data
        Storage location of the first derivative of the Gaussian in the Y direction for 2D images;
      • 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.
      • kExtents

        private int[] kExtents
        Extents of the kernel.
      • red

        private boolean red
        Flags indicate which color channel to process. True indicates the channel should be processed.
      • sigmas

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

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

      • AlgorithmGradientMagnitude

        public AlgorithmGradientMagnitude​(ModelImage srcImg,
                                          float[] sigmas,
                                          boolean maskFlag,
                                          boolean img25D)
        Creates a new AlgorithmGradientMagnitude object.
        Parameters:
        srcImg - source image model
        sigmas - Gaussian standard deviations in each dimension
        maskFlag - Flag, if true, indicates that the gradient magnitude will be calculated for the whole image
        img25D - Flag, if true, indicates that each slice of the 3D volume should be processed independently. 2D images disregard this flag.
      • AlgorithmGradientMagnitude

        public AlgorithmGradientMagnitude​(ModelImage destImg,
                                          ModelImage srcImg,
                                          float[] sigmas,
                                          boolean maskFlag,
                                          boolean img25D)
        Creates a new AlgorithmGradientMagnitude object.
        Parameters:
        destImg - image model where result image is to stored
        srcImg - source image model
        sigmas - Gaussian standard deviations in each dimension
        maskFlag - Flag, if true, indicates that the gradient magnitude will be calculated for the whole image
        img25D - Flag, if true, indicates that each slice of the 3D volume should be processed independently. 2D images disregard this flag.
    • Method Detail

      • calcInBuffer2D

        public float[] calcInBuffer2D​(float[] buffer,
                                      int[] extents,
                                      boolean color,
                                      float[] xDirs,
                                      float[] yDirs)
        Calculates the gradient magnitude of a 2D image and returns it as a float buffer.
        Parameters:
        buffer - DOCUMENT ME!
        extents - DOCUMENT ME!
        color - DOCUMENT ME!
        xDirs - DOCUMENT ME!
        yDirs - DOCUMENT ME!
        Returns:
        Buffer with the gradient magnitude of the image.
      • calcInBuffer2DUnnormalized

        public float[] calcInBuffer2DUnnormalized​(float[] buffer,
                                                  int[] extents,
                                                  boolean color,
                                                  float[] xDirs,
                                                  float[] yDirs)
        Calculates the gradient magnitude of a 2D image and returns it as a float buffer.
        Parameters:
        buffer - DOCUMENT ME!
        extents - DOCUMENT ME!
        color - DOCUMENT ME!
        xDirs - DOCUMENT ME!
        yDirs - DOCUMENT ME!
        Returns:
        Buffer with the gradient magnitude of the image.
      • finalize

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

        public void setBlue​(boolean flag)
        Sets the flag for the blue channel.
        Parameters:
        flag - if set to true then the blue channel is processed.
      • setGreen

        public void setGreen​(boolean flag)
        Sets the flag for the green channel.
        Parameters:
        flag - if set to true then the green channel is processed.
      • setRed

        public void setRed​(boolean flag)
        Sets the flag for the red channel.
        Parameters:
        flag - if set to true then the red channel is processed.
      • calcInPlace2D

        private void calcInPlace2D​(int nImages)
        Calculates the gradient image and replaces the source image with the new image.
        Parameters:
        nImages - number of images on which to calculate the gradient magnitude. If 2D image then nImage = 1. If 3D image where each image is to processed independently then nImages equals the number of images in the volume.
      • calcInPlace2DBuffer

        private float[] calcInPlace2DBuffer​(int nImages,
                                            float[] buffer,
                                            int[] extents,
                                            boolean color,
                                            float[] xDirections,
                                            float[] yDirections)
        Calculates the gradient image and returns a float buffer with the new values.
        Parameters:
        nImages - number of images on which to calculate the gradient magnitude. If 2D image then nImage = 1. If 3D image where each image is to processed independently then nImages equals the number of images in the volume.
        buffer - DOCUMENT ME!
        extents - DOCUMENT ME!
        color - DOCUMENT ME!
        xDirections - DOCUMENT ME!
        yDirections - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • calcInPlace2DBufferUnnormalized

        private float[] calcInPlace2DBufferUnnormalized​(int nImages,
                                                        float[] buffer,
                                                        int[] extents,
                                                        boolean color,
                                                        float[] xDirections,
                                                        float[] yDirections)
        Calculates the gradient image and returns a float buffer with the new values.
        Parameters:
        nImages - number of images on which to calculate the gradient magnitude. If 2D image then nImage = 1. If 3D image where each image is to processed independently then nImages equals the number of images in the volume.
        buffer - DOCUMENT ME!
        extents - DOCUMENT ME!
        color - DOCUMENT ME!
        xDirections - DOCUMENT ME!
        yDirections - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • calcInPlace34D

        private void calcInPlace34D()
        Calculates the gradient magnitude image and replaces the source image with the new image.
      • calcStoreInDest2D

        private void calcStoreInDest2D​(int nImages)
        This function produces the gradient magnitude of input image.
        Parameters:
        nImages - number of images on which to calculate the gradient magnitude. If 2D image then nImage = 1. If 3D image where each image is to processed independently then nImages equals the number of images in the volume.
      • calcStoreInDest34D

        private void calcStoreInDest34D()
        This function produces the gradient magnitude of input image.
      • makeKernels2D

        private void makeKernels2D()
        Creates Gaussian derivative kernels.
      • makeKernels3D

        private void makeKernels3D()
        Creates Gaussian derivative kernels.
      • 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