Class AlgorithmGaussianBlurSep
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.filters.AlgorithmGaussianBlurSep
-
- All Implemented Interfaces:
AlgorithmInterface
,java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmGaussianBlurSep extends AlgorithmBase implements AlgorithmInterface
Calculates the gaussian blur of an image at a scale defined by the user (using separable convolutions). Adapted from AlgorithmGaussianBlur. This version should be faster but uses significantly more memory.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
entireImage
Flag, if true, indicates that the whole image should be processed.private Kernel
gaussianKernel
private boolean
green
Flags indicate which color channel to process.private float[]
inputBuffer
private float[]
outputBuffer
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 AlgorithmGaussianBlurSep(ModelImage srcImg, float[] sigmas, boolean maskFlag, boolean img25D)
Creates a new AlgorithmGaussianBlurSep object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterExecute()
void
algorithmPerformed(AlgorithmBase algorithm)
Called after an algorithm this listener is registered to exits (maybe successfully, maybe not).void
beforeExecute()
void
execute()
void
finalize()
Prepares this class for destruction.float[]
getResultBuffer()
void
runAlgorithm()
Starts the program.void
setBlue(boolean flag)
Sets the flag for the blue channel.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.
-
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.
-
gaussianKernel
private Kernel gaussianKernel
-
inputBuffer
private float[] inputBuffer
-
outputBuffer
private float[] outputBuffer
-
-
Constructor Detail
-
AlgorithmGaussianBlurSep
public AlgorithmGaussianBlurSep(ModelImage srcImg, float[] sigmas, boolean maskFlag, boolean img25D)
Creates a new AlgorithmGaussianBlurSep object.- Parameters:
srcImg
- source image modelsigmas
- Gaussian's standard deviations in the each dimensionmaskFlag
- Flag that indicates that the gaussian convolution will be performed over the whole image if equal to trueimg25D
- Flag, if true, indicates that each slice of the 3D volume should be processed independently. 2D images disregard this flag.
-
-
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
-
beforeExecute
public void beforeExecute()
-
execute
public void execute()
-
afterExecute
public void afterExecute()
-
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.
-
getResultBuffer
public float[] getResultBuffer()
-
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
-
-