Class AlgorithmRegularizedIsotropicDiffusion
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.filters.AlgorithmRegularizedIsotropicDiffusion
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmRegularizedIsotropicDiffusion extends AlgorithmBase
Algorithm to apply Regularized Isotropic Nonlinear Diffusion as described by:Joachim Weickert Chapter 15 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
Here is a listing of the author's terminology used in the title.
- Regularized the computed image is blurred with a Gaussian kernel prior to taking finite derivatives
- Isotropic the gradient and flux are parallel
- Nonlinear the weights used for combining pixels change over the image, space variant.
- Diffusion this model uses the heat equation
- Version:
- 1.0; 31, July 2003
- Author:
- Paul F. Hemler, Ph.D.
-
-
Field Summary
Fields Modifier and Type Field Description private AlgorithmSeparableConvolver
algoSepConvolver
Handle to the separable convolution kernel.private AlgorithmSeparableConvolver
algoSepConvolverB
Handle to the separable convolution kernel.private AlgorithmSeparableConvolver
algoSepConvolverG
Handle to the separable convolution kernel.private AlgorithmSeparableConvolver
algoSepConvolverR
Handle to the separable convolution kernel.private float
contrast
Diffusion contrast parameter.private boolean
do25D
Flag indicating 2.5D processing.private float
lambda
Contrast multiplied by the maximum gradient.(package private) int
numIterations
The number of iterations.private float[]
sigmas
Standard deviations of the gaussian used to calculate the kernels.private float
stdDev
Standard deviation used for the Gaussians.(package private) float
timeStep
The time parameter step size, called tau in the algorithm description In 2D for stability the time step should beprivate float[]
xDataRound
Storage location for the 1D gaussian kernels.private int
xDim
Image dimensions.private float[]
yDataRound
Storage location for the 1D gaussian kernels.private int
yDim
Image dimensions.private float[]
zDataRound
Storage location for the 1D gaussian kernels.private int
zDim
Image dimensions.-
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 AlgorithmRegularizedIsotropicDiffusion(ModelImage destImg, ModelImage srcImg, int numI, float stdDev, float contrast, boolean do25D)
Creates a new AlgorithmRegularizedIsotropicDiffusion object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private float
diffusivity(float d)
Returns the weighting for values used in computing new (diffused) pixel values.void
finalize()
Prepares this class for destruction.private float
getVal(float[] buffer, int col, int row)
Returns the value in a 2D image buffer of the pixel at location col, row.private float
getVal(float[] buffer, int col, int row, int slice)
Returns the value in a 3D image buffer of the pixel at location col, row, slice.private void
gradientMagnitude(float[] img, float[] mag)
Computes the gradient magnitude of the buffer passed in.private void
gradientMagnitude3D(float[] img, float[] mag)
Computes the gradient magnitude of the buffer passed in.private void
makeKernels1D(boolean do3D)
DOCUMENT ME!private void
run2D(int numImages)
Iterates the Regularized Isotropic Nonlinear Diffusion algorithm for 2D and 2.5D images.private void
run2DC(int numImages)
Iterates the Regularized Isotropic Nonlinear Diffusion algorithm for 2D and 2.5D color images.private void
run3D()
Iterates the Regularized Isotropic Nonlinear Diffusion algorithm for 3D images.private void
run3DC()
Iterates the Regularized Isotropic Nonlinear Diffusion algorithm for 3D color images.void
runAlgorithm()
Starts the program.private void
upDateImage(float[] resltBuffer, float[] srcBuffer, float[] gradBuffer)
DOCUMENT ME!private void
upDateImage3D(float[] resltBuffer, float[] srcBuffer, float[] gradBuffer)
DOCUMENT ME!-
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
-
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-
algoSepConvolver
private AlgorithmSeparableConvolver algoSepConvolver
Handle to the separable convolution kernel.
-
algoSepConvolverB
private AlgorithmSeparableConvolver algoSepConvolverB
Handle to the separable convolution kernel.
-
algoSepConvolverG
private AlgorithmSeparableConvolver algoSepConvolverG
Handle to the separable convolution kernel.
-
algoSepConvolverR
private AlgorithmSeparableConvolver algoSepConvolverR
Handle to the separable convolution kernel.
-
contrast
private float contrast
Diffusion contrast parameter.
-
do25D
private boolean do25D
Flag indicating 2.5D processing.
-
lambda
private float lambda
Contrast multiplied by the maximum gradient.
-
sigmas
private float[] sigmas
Standard deviations of the gaussian used to calculate the kernels.
-
stdDev
private float stdDev
Standard deviation used for the Gaussians.
-
xDataRound
private float[] xDataRound
Storage location for the 1D gaussian kernels.
-
xDim
private int xDim
Image dimensions.
-
yDim
private int yDim
Image dimensions.
-
zDim
private int zDim
Image dimensions.
-
yDataRound
private float[] yDataRound
Storage location for the 1D gaussian kernels.
-
zDataRound
private float[] zDataRound
Storage location for the 1D gaussian kernels.
-
Constructor Detail
-
AlgorithmRegularizedIsotropicDiffusion
public AlgorithmRegularizedIsotropicDiffusion(ModelImage destImg, ModelImage srcImg, int numI, float stdDev, float contrast, boolean do25D)
Creates a new AlgorithmRegularizedIsotropicDiffusion object.- Parameters:
destImg
- ModelImage image model where result image is to storedsrcImg
- ModelImage source image modelnumI
- int number of iterationsstdDev
- float standard deviation used in the Gaussianscontrast
- float diffusion contrast parameterdo25D
- boolean If true, process each slice separately
-
-
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
-
diffusivity
private float diffusivity(float d)
Returns the weighting for values used in computing new (diffused) pixel values.- Parameters:
d
- float Value to compute the diffusivity- Returns:
- float The value of the diffusivity corresponding to the d value
-
getVal
private float getVal(float[] buffer, int col, int row)
Returns the value in a 2D image buffer of the pixel at location col, row.- Parameters:
buffer
- float[] The image buffercol
- int Column indexrow
- 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 col, row, slice.- Parameters:
buffer
- float[] The image buffercol
- int Column indexrow
- int Row indexslice
- int Slice index- Returns:
- float The pixel value
-
gradientMagnitude
private void gradientMagnitude(float[] img, float[] mag)
Computes the gradient magnitude of the buffer passed in. This version computes values for the image borders and corners- Parameters:
img
- float [] source buffermag
- float [] a buffer where the gradient magnitude will be placed
-
gradientMagnitude3D
private void gradientMagnitude3D(float[] img, float[] mag)
Computes the gradient magnitude of the buffer passed in. This version computes values for the image borders and corners- Parameters:
img
- float [] source buffermag
- float [] a buffer where the gradient magnitude will be placed
-
makeKernels1D
private void makeKernels1D(boolean do3D)
DOCUMENT ME!- Parameters:
do3D
- boolean Flag indicating if a 3D kernel should be computed
-
run2D
private void run2D(int numImages)
Iterates the Regularized Isotropic Nonlinear Diffusion algorithm for 2D and 2.5D images.- Parameters:
numImages
- int number of images to be blurred. If 2D image then nImage = 1, if 3D image where each slice is to processed independently then nImages equals the number of slices in the volume.
-
run2DC
private void run2DC(int numImages)
Iterates the Regularized Isotropic Nonlinear Diffusion algorithm for 2D and 2.5D color images.- Parameters:
numImages
- int number of slices to be blurred. If 2D image then nImage = 1, if 3D image where each slice is to processed independently then nImages equals the number of slices in the volume.
-
run3D
private void run3D()
Iterates the Regularized Isotropic Nonlinear Diffusion algorithm for 3D images.
-
run3DC
private void run3DC()
Iterates the Regularized Isotropic Nonlinear Diffusion algorithm for 3D color images.
-
upDateImage
private void upDateImage(float[] resltBuffer, float[] srcBuffer, float[] gradBuffer)
DOCUMENT ME!- Parameters:
resltBuffer
- float [] The preallocated result buffersrcBuffer
- float [] The initialized source buffer containing the input imagegradBuffer
- float [] The initialized buffer containing the magnitude of the gradient of the Gaussian blurred input image
-
upDateImage3D
private void upDateImage3D(float[] resltBuffer, float[] srcBuffer, float[] gradBuffer)
DOCUMENT ME!- Parameters:
resltBuffer
- float [] The preallocated result buffersrcBuffer
- float [] The initialized source buffer containing the input imagegradBuffer
- float [] The initialized buffer containing the magnitude of the gradient of the Gaussian blurred input image
-
-
-
-