Class AlgorithmCoherenceEnhancingDiffusion
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.filters.AlgorithmCoherenceEnhancingDiffusion
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmCoherenceEnhancingDiffusion extends AlgorithmBase
Algorithm to apply Coherence Enhancing Anisotropic Diffusion
For color form a common structure tensor for all colors by averaging the structure tensors for each color.
References:
- Joachim Weickert
Chapter 15 Nonlinear Diffusion Filtering 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 - Algorithms for Non-Linear Diffusion Matlab in a Literate Programming Style by Rein van den Boomgaard, Intelligent Sensory Information Systems, University of Amsterdam, The Netherlands http://carol.wins.uva.nl/~rein/nldiffusionweb/material.html
- Coherence-Enhancing Diffusion of Colour Images by Joachim Weickert, A. Sanfeliu, J.J. Villanueva, J. Vitria, editors, Proc. VII National Symposium on Pattern Recognition and Image Analysis (VII NSPRIA, Barcelona, April 21-25, 1997), Vol. 1, pp. 239-244, 1997.
- Coherence-Enhancing Diffusion of Colour Images by Joachim Weickert, Image and Vision Computing, Vol. 17, 1999, pp. 201-212.
- Coherence-Enhancing Diffusion Filtering by Joachim Weickert, International Journal of Computer Vision, Vol. 31, No. 2/3, pp. 111-127, April, 1999
- Version:
- 1.0; 31, July 2003
- Author:
- Paul F. Hemler, Ph.D.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) float
derivativeScale
Gaussian scale for derivative operations.(package private) boolean
do25D
flag indicating 2.5D processing.private float[]
dxKernelX
Kernels for the X derivative.private float[]
dxKernelY
DOCUMENT ME!private float[]
dxKernelZ
DOCUMENT ME!private float[]
dyKernelX
Kernels for the Y derivative.private float[]
dyKernelY
DOCUMENT ME!private float[]
dyKernelZ
DOCUMENT ME!private float[]
dzKernelX
Kernels for the Z derivative.private float[]
dzKernelY
DOCUMENT ME!private float[]
dzKernelZ
DOCUMENT ME!private WildMagic.LibFoundation.NumericalAnalysis.Eigenf
eigenSystemAlgo
Eigensystem solver.private boolean
entireImage
Whether to process the entire image, or just the portion within the currently selected VOI.(package private) float
gaussianScale
Gaussian scale for structure tensor smoothing.private float[]
intermediateBuffer
Reference to intermediate buffer.(package private) double
k
diffusitivity denominator.(package private) double
k2
diffusitivity denominator squared.private int
kRadius
Width of the derivative buffer.(package private) int
numIterations
The number of iterations.private float[]
skernelX
Kernels for the Smoothing kernel.private float[]
skernelY
DOCUMENT ME!private float[]
skernelZ
DOCUMENT ME!private int
skRadius
Width of the smoothing buffer.(package private) float
timeStep
The time parameter step size, called tau in the algorithm description In 2D for stability the time step should beprivate int
xDim
image dimensions.private int
yDim
image dimensions.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 AlgorithmCoherenceEnhancingDiffusion(ModelImage srcImg, int numI, float k, float derivativeScale, float gaussianScale, boolean do25D, boolean entireImage)
Creates a new AlgorithmCoherenceEnhancingDiffusion object.AlgorithmCoherenceEnhancingDiffusion(ModelImage destImg, ModelImage srcImg, int numI, float k, float derivativeScale, float gaussianScale, boolean do25D, boolean entireImage)
Creates a new AlgorithmCoherenceEnhancingDiffusion object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
computeDx(float[] dx, float[] src)
DOCUMENT ME!private void
computeDx3D(float[] dx, float[] src)
DOCUMENT ME!private void
computeDy(float[] dy, float[] src)
DOCUMENT ME!private void
computeDy3D(float[] dy, float[] src)
DOCUMENT ME!private void
computeDz(float[] dz, float[] src)
DOCUMENT ME!void
finalize()
Prepares this class for destruction.private void
gaussianSmooth(float[] gs, float[] src)
DOCUMENT ME!private void
gaussianSmooth3D(float[] gs, float[] src)
DOCUMENT ME!private float
getVal(float[] buffer, int col, int row)
Returns the value in a 2D image buffer of the pixel at location row, col.private float
getVal(float[] buffer, int col, int row, int slice)
Returns the value in a 3D image buffer of the pixel at location slice, row, col.private void
init()
Initialize buffers and kernels.private static float
max(float a, float b)
Computes the maximum of two floating point numbers passed in.private void
run2D(int numImages)
Starts the algorithm for 2D images.private void
run2DC(int numImages)
Starts the algorithm for 2D images.private void
run3D()
Starts the algorithm for 3D images.private void
run3DC()
Starts the algorithm for 3D color images.void
runAlgorithm()
Starts the program.private void
setVal(float val, float[] buffer, int col, int row)
Sets the value in a 2D image buffer at location row, col.private void
setVal(float val, float[] buffer, int col, int row, int slice)
Sets the value in a 3D image buffer at location row, col.-
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
-
derivativeScale
float derivativeScale
Gaussian scale for derivative operations.
-
do25D
boolean do25D
flag indicating 2.5D processing.
-
gaussianScale
float gaussianScale
Gaussian scale for structure tensor smoothing.
-
k
double k
diffusitivity denominator.
-
k2
double k2
diffusitivity denominator squared.
-
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-
dxKernelX
private float[] dxKernelX
Kernels for the X derivative.
-
dxKernelY
private float[] dxKernelY
DOCUMENT ME!
-
dxKernelZ
private float[] dxKernelZ
DOCUMENT ME!
-
dyKernelX
private float[] dyKernelX
Kernels for the Y derivative.
-
dyKernelY
private float[] dyKernelY
DOCUMENT ME!
-
dyKernelZ
private float[] dyKernelZ
DOCUMENT ME!
-
dzKernelX
private float[] dzKernelX
Kernels for the Z derivative.
-
dzKernelY
private float[] dzKernelY
DOCUMENT ME!
-
dzKernelZ
private float[] dzKernelZ
DOCUMENT ME!
-
eigenSystemAlgo
private WildMagic.LibFoundation.NumericalAnalysis.Eigenf eigenSystemAlgo
Eigensystem solver.
-
entireImage
private boolean entireImage
Whether to process the entire image, or just the portion within the currently selected VOI.
-
intermediateBuffer
private float[] intermediateBuffer
Reference to intermediate buffer.
-
kRadius
private int kRadius
Width of the derivative buffer.
-
skernelX
private float[] skernelX
Kernels for the Smoothing kernel.
-
skernelY
private float[] skernelY
DOCUMENT ME!
-
skernelZ
private float[] skernelZ
DOCUMENT ME!
-
skRadius
private int skRadius
Width of the smoothing buffer.
-
xDim
private int xDim
image dimensions.
-
yDim
private int yDim
image dimensions.
-
zDim
private int zDim
image dimensions.
-
Constructor Detail
-
AlgorithmCoherenceEnhancingDiffusion
public AlgorithmCoherenceEnhancingDiffusion(ModelImage srcImg, int numI, float k, float derivativeScale, float gaussianScale, boolean do25D, boolean entireImage)
Creates a new AlgorithmCoherenceEnhancingDiffusion object.- Parameters:
srcImg
- Source image modelnumI
- Number of iterationsk
- Diffusitivity denominatorderivativeScale
- Scale of the gaussian when taking derivativesgaussianScale
- Scale of the gaussian for smoothing the structure tensordo25D
- Flag indicating 2.5D processingentireImage
- whether to filter the entire image or just the VOI region
-
AlgorithmCoherenceEnhancingDiffusion
public AlgorithmCoherenceEnhancingDiffusion(ModelImage destImg, ModelImage srcImg, int numI, float k, float derivativeScale, float gaussianScale, boolean do25D, boolean entireImage)
Creates a new AlgorithmCoherenceEnhancingDiffusion object.- Parameters:
destImg
- Image model where result image is to storedsrcImg
- Source image modelnumI
- Number of iterationsk
- Diffusitivity denominatorderivativeScale
- Scale of the gaussian when taking derivativesgaussianScale
- Scale of the gaussian for smoothing the structure tensordo25D
- Flag indicating 2.5D processingentireImage
- whether to filter the entire image or just the VOI region
-
-
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
-
max
private static float max(float a, float b)
Computes the maximum of two floating point numbers passed in.- Parameters:
a
- float The first valueb
- float The second value- Returns:
- float The maximum of values a and b
-
computeDx
private void computeDx(float[] dx, float[] src)
DOCUMENT ME!- Parameters:
dx
- float [] destination buffersrc
- float [] source bufferMember function computes the derivative of the source buffer in the X-direction using the kernel formulation as specified in the MATLAB paper. The function uses seperable convolution, which means it first does a 1D convolution with the derivative of a Gaussian kernel in the X-direction and stores the result in an intermediate buffer. Once the intermediate buffer is completely filled, a smoothing in the Y-direction is performed using a 1D Gaussian kernel computed as in the MATLAB paper.
-
computeDx3D
private void computeDx3D(float[] dx, float[] src)
DOCUMENT ME!- Parameters:
dx
- float [] destination buffersrc
- float [] source bufferMember function computes the derivative of the source buffer in the X-direction using the kernel formulation as specified in the MATLAB paper. The function uses seperable convolution, which means it first does a 1D convolution with the derivative of a Gaussian kernel in the X-direction and stores the result in dx buffer. Once dx is completely filled, a smoothing in the Y-direction is performed using a 1D Gaussian kernel and the intermediate result is stored in intermediateBuffer. Once intermediateBuffer is completely filled, a smoothing in the Z-direction is performed and the final result is placed in dx.
-
computeDy
private void computeDy(float[] dy, float[] src)
DOCUMENT ME!- Parameters:
dy
- float [] destination buffersrc
- float [] source bufferMember function computes the derivative of the source buffer in the Y-direction using the kernel formulation as specified in the MATLAB paper. The function uses seperable convolution, which means it first does a 1D convolution with a Gaussian kernel in the X-direction and stores the result in an intermediate buffer. Once the intermediate buffer is completely filled, a 1D convolution in the Y-direction is performed using a 1D Gaussian derivative kernel computed as in the MATLAB paper.
-
computeDy3D
private void computeDy3D(float[] dy, float[] src)
DOCUMENT ME!- Parameters:
dy
- float [] destination buffersrc
- float [] source bufferMember function computes the derivative of the source buffer in the Y-direction using the kernel formulation as specified in the MATLAB paper. The function uses seperable convolution, which means it first does a 1D smoothing convolution with a Gaussian kernel in the X-direction and stores the result in dy buffer. Once dy is completely filled, a convolution in the Y-direction is performed using the derivative of a 1D Gaussian kernel and the intermediate result is stored in intermediateBuffer. Once intermediateBuffer is completely filled, a smoothing in the Z-direction is performed and the final result is placed in dy.
-
computeDz
private void computeDz(float[] dz, float[] src)
DOCUMENT ME!- Parameters:
dz
- float [] destination buffersrc
- float [] source bufferMember function computes the derivative of the source buffer in the Z-direction using the kernel formulation as specified in the MATLAB paper. The function uses seperable convolution, which means it first does a 1D convolution with a Gaussian kernel in the X-direction and stores the result in dz buffer. Once dz is completely filled, a smoothing in the Y-direction is performed using a 1D Gaussian kernel and the intermediate result is stored in intermediateBuffer. Once intermediateBuffer is completely filled, a convolution with the derivative of a Gaussian kernel in the Z-direction is performed and the final result is placed in dz.
-
gaussianSmooth
private void gaussianSmooth(float[] gs, float[] src)
DOCUMENT ME!- Parameters:
gs
- float [] destination buffersrc
- float [] source bufferMember function gaussian smoothes the source buffer in the x and y directions using the kernel formulation as specified in the MATLAB paper. The function uses seperable convolution, which means it first does a 1D convolution with a Gaussian kernel in the X-direction and stores the result in an intermediate buffer. Once the intermediate buffer is completely filled, a 1D convolution in the Y-direction is performed using a 1D Gaussian kernel.
-
gaussianSmooth3D
private void gaussianSmooth3D(float[] gs, float[] src)
DOCUMENT ME!- Parameters:
gs
- float [] destination buffersrc
- float [] source bufferMember function gaussian smoothes the source buffer in the x,y, and z directions using the kernel formulation as specified in the MATLAB paper. The function uses seperable convolution, which means it first does a 1D convolution with a Gaussian kernel in the X-direction and stores the result in gs. Once the gs buffer is completely filled, a 1D convolution in the Y-direction is performed using a 1D Gaussian kernel and the result is stored in intermediateBuffer. Once intermediateBuffer is completely filled, a 1D convolution in the Z-direction is performed using a 1D Gaussian kernel and the result is placed in gs.
-
getVal
private float getVal(float[] buffer, int col, int row)
Returns the value in a 2D image buffer of the pixel at location row, col.- 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 slice, row, col.- Parameters:
buffer
- float[] The image buffercol
- int Column indexrow
- int Row indexslice
- int Slice index- Returns:
- float The pixel value
-
init
private void init()
Initialize buffers and kernels.
-
run2D
private void run2D(int numImages)
Starts the algorithm for 2D images.- Parameters:
numImages
- int The number of 2D images
-
run2DC
private void run2DC(int numImages)
Starts the algorithm for 2D images.- Parameters:
numImages
- int The number of 2D images
-
run3D
private void run3D()
Starts the algorithm for 3D images.
-
run3DC
private void run3DC()
Starts the algorithm for 3D color images.
-
setVal
private void setVal(float val, float[] buffer, int col, int row)
Sets the value in a 2D image buffer at location row, col.- Parameters:
val
- float The value to set the pixel tobuffer
- float[] 2D image buffercol
- int Column indexrow
- int Row index
-
setVal
private void setVal(float val, float[] buffer, int col, int row, int slice)
Sets the value in a 3D image buffer at location row, col.- Parameters:
val
- float The value to set the pixel tobuffer
- float[] 3D image buffercol
- int Column indexrow
- int Row indexslice
- int Slice index
-
-
-
-