Class AlgorithmGaussianBlur

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

    public class AlgorithmGaussianBlur
    extends AlgorithmBase
    implements AlgorithmInterface
    The application of this algorithm blurs an image or VOI region of the image with a Gaussian function at a user defined scale (sigma - standard deviation). In essence, convolving a Gaussian function produces the same result as a low-pass or smoothing filter. A low-pass filter attenuates high frequency components of the image (i.e. edges) and passes low frequency components and thus results in the blurring of the image. Smoothing filters are typically used for noise reduction and for blurring. The standard deviation (SD) of the Gaussian function controls the amount of blurring:a large SD (i.e. > 2) significantly blurs while a small SD (i.e. 0.5) blurs less. If the objective is to achieve noise reduction, a rank filter (median) might be more useful.

    1D Gaussian = (1/sqrt(2*PI*sigma*sigma))*exp(-x*x/(2*sigma*sigma));

    Advantages to convolving the Gaussian function to blur an image include:

    1. Structure will not be added to the image. 2. Can be analytically calculated, as well as the Fourier Transform of the Gaussian. 3. By varying the SD a Gaussian scale-space can easily be constructed.

    Version:
    0.1 Feb 11, 1998
    Author:
    Matthew J. McAuliffe, Ph.D.
    See Also:
    GenerateGaussian, AlgorithmConvolver
    • Field Detail

      • entireImage

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

        private float[] GaussData
        Storage location of the Gaussian kernel.
      • kExtents

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

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

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

        private boolean blue
        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.
      • doMultiThread

        private boolean doMultiThread
    • Constructor Detail

      • AlgorithmGaussianBlur

        public AlgorithmGaussianBlur​(ModelImage srcImg,
                                     float[] sigmas,
                                     boolean maskFlag,
                                     boolean img25D)
        Creates a new AlgorithmGaussianBlur object.
        Parameters:
        srcImg - DOCUMENT ME!
        sigmas - DOCUMENT ME!
        maskFlag - DOCUMENT ME!
        img25D - DOCUMENT ME!
      • AlgorithmGaussianBlur

        public AlgorithmGaussianBlur​(ModelImage destImg,
                                     ModelImage srcImg,
                                     float[] sigmas,
                                     boolean maskFlag,
                                     boolean img25D)
        Constructor which sets the source and destination images, the minimum and maximum progress value.
        Parameters:
        destImg - the destination image
        srcImg - the source image
        sigmas - the sigmas
        maskFlag - the mask flag
        img25D - the 2.5D indicator
    • Method Detail

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

        public void setDoMultiThread​(boolean doMultiThread)
        Parameters:
        doMultiThread -
      • calcInPlace2D

        private void calcInPlace2D​(int nImages)
        Calculates the blurred image and replaces the source image with the blurred image.
        Parameters:
        nImages - number of images to be blurred. 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.
      • calcInPlace3D

        private void calcInPlace3D()
        Calculates the blurred image and replaces the source image with the blurred image.
      • calcInPlace4D

        private void calcInPlace4D()
        Calculates the blurred image and replaces the source image with the blurred image.
      • calcStoreInDest2D

        private void calcStoreInDest2D​(int nImages)
        This function produces a new image that has been blurred.
        Parameters:
        nImages - number of images to be blurred. 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.
      • calcStoreInDest3D

        private void calcStoreInDest3D()
        Produces a new image that has been blurred.
      • convolve2D

        private final void convolve2D​(int startSlice,
                                      int endSlice)
      • convolve3DRGB

        private final void convolve3DRGB​(int start,
                                         int end,
                                         float[] iImage,
                                         int index)
      • convolve3D

        private final void convolve3D​(int start,
                                      int end,
                                      float[] iImage,
                                      int index)
      • calcStoreInDest4D

        private void calcStoreInDest4D()
        Produces a new image that has been blurred.
      • makeKernels2D

        private void makeKernels2D()
        Creates 2D Gaussian kernels for the blurring process. The kernel size is always odd and proportional (8X) to the standard deviation of the Gaussian.
      • makeKernels3D

        private void makeKernels3D()
        Creates 3D Gaussian kernels for the blurring process. The kernel size is always odd and proportional (8X) to the standard deviation of the Gaussian.
      • 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