Class AlgorithmGaussianBlur
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.filters.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 Summary
Fields Modifier and Type Field Description private boolean
blue
Flags indicate which color channel to process.private boolean
doMultiThread
private boolean
entireImage
Flag, if true, indicates that the whole image should be processed.private float[]
GaussData
Storage location of the Gaussian kernel.private boolean
green
Flags indicate which color channel to process.private int[]
kExtents
Dimensionality of the kernel.private boolean
red
Flags indicate which color channel to process.private float[]
sigmas
Standard deviations of the gaussian used to calculate the kernels.-
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStopped
-
-
Constructor Summary
Constructors Constructor Description AlgorithmGaussianBlur(ModelImage srcImg, float[] sigmas, boolean maskFlag, boolean img25D)
Creates a new AlgorithmGaussianBlur object.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
algorithmPerformed(AlgorithmBase algorithm)
Called after an algorithm this listener is registered to exits (maybe successfully, maybe not).private void
calcInPlace2D(int nImages)
Calculates the blurred image and replaces the source image with the blurred image.private void
calcInPlace3D()
Calculates the blurred image and replaces the source image with the blurred image.private void
calcInPlace4D()
Calculates the blurred image and replaces the source image with the blurred image.private void
calcStoreInDest2D(int nImages)
This function produces a new image that has been blurred.private void
calcStoreInDest3D()
Produces a new image that has been blurred.private void
calcStoreInDest4D()
Produces a new image that has been blurred.private void
convolve2D(int startSlice, int endSlice)
private void
convolve3D(int start, int end, float[] iImage, int index)
private void
convolve3DRGB(int start, int end, float[] iImage, int index)
void
finalize()
Prepares this class for destruction.private void
makeKernels2D()
Creates 2D Gaussian kernels for the blurring process.private void
makeKernels3D()
Creates 3D Gaussian kernels for the blurring process.void
runAlgorithm()
Starts the program.void
setBlue(boolean flag)
Sets the flag for the blue channel.void
setDoMultiThread(boolean doMultiThread)
void
setGreen(boolean flag)
Sets the flag for the green channel.void
setRed(boolean flag)
Sets the flag for the red channel.-
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, generateProgressValues, getDestImage, getElapsedTime, getMask, getMaxProgressValue, getMinProgressValue, getNumberOfThreads, getProgress, getProgressChangeListener, getProgressChangeListeners, getProgressModulus, getProgressStep, getProgressValues, getSrcImage, isCompleted, isImage25D, isMultiThreadingEnabled, isRunningInSeparateThread, isThreadStopped, linkProgressToAlgorithm, linkProgressToAlgorithm, makeProgress, notifyListeners, removeListener, removeProgressChangeListener, run, setCompleted, setImage25D, setMask, setMaxProgressValue, setMinProgressValue, setMultiThreadingEnabled, setNumberOfThreads, setProgress, setProgressModulus, setProgressStep, setProgressValues, setProgressValues, setRunningInSeparateThread, setSrcImage, setStartTime, setThreadStopped, startMethod, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
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 imagesrcImg
- the source imagesigmas
- the sigmasmaskFlag
- the mask flagimg25D
- the 2.5D indicator
-
-
Method Detail
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()
Starts the program.- Specified by:
runAlgorithm
in classAlgorithmBase
-
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 interfaceAlgorithmInterface
- Parameters:
algorithm
- the algorithm which has just completed
-
-