Class AlgorithmFastMarching
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.AlgorithmFastMarching
-
- All Implemented Interfaces:
AlgorithmInterface
,java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmFastMarching extends AlgorithmBase implements AlgorithmInterface
DOCUMENT ME!- Version:
- 0.1 March 6, 1998
- Author:
- Matthew J. McAuliffe, Ph.D.
This algorithm iteratively expands a contour to a boundary.
This version of the anisotropic diffusion equation is: dI/dt = div[g(normalized grad magnitude(image))* grad I], where g() is the edge stopping function. The original edge stopping function used was the Perona and Malik function: g(x) = 1/(1 + (x**2/k**2)). However, as outlined in "Robust Anisotropic Diffusion" by Michael J. Black, Guillermo Sapiro, David H. Marimont, and David Heeger, IEEE Transactions on Image Processing, Vol. 7, No. 3, March 1998, pp. 421-432, the Perona and Malik function gives outliers(large values of grad(image)) too much influence. Thus, the Perona and Malik function was replaced with the Tukey's biweight function: g(x) = 0.5 * [1 - (x/k)**2]**2 for abs(x) <= k = 0 otherwise.
The normalized gradient magnitude of the image goes from 0 to 100. In the above equation I is a VOI intensity, where initially all the VOI area is assigned 100 and the rest of the image is assigned 0. The equation is discretized as: I(x,y,z,t+1) = I(x,y,z,t) + 0.25*g(normalized grad magnitude(image(x,y,z)))* (I(x+gradX,y+gradY,z+gradZ,t) - I(x,y,z,t)), where gradX, gradY, and gradZ are the normalized gradient measurements of I. The value of I is clamped to a maximum value of 100 and the value of I is not changed if either its value has fallen to be <= 3 or the values of all 4 of its nearest neighbors are <= 3. Note that the name AlgorithmLevelSet is misleading because the equation used is a version of the anisotropic diffusion equation and not a version of the level set equation given by Osher and Sethian: d(phi)/dt + F*|grad(phi)| = 0, given phi(x,y,z,t=0). For more information on the Anisotropic diffusion equation see: Geometry-Driven Diffusion in Computer Vision edited by Bart M. ter Haar Romeny, Chapter 3 on Anisotropic Diffusion by Pietro Perona, Takahiro Shiota, and Jitendra Malik, pages 73-92, Kluwer Academic Publishers, 1994.
-
-
Field Summary
Fields Modifier and Type Field Description private float[]
edgeImage
DOCUMENT ME!private float[]
GxData
Storage location of the first derivative of the Gaussian in the X direction.private float[]
GyData
Storage location of the first derivative of the Gaussian in the Y direction.private float[]
GzData
Storage location of the first derivative of the Gaussian in the Z direction.private int
iterations
Number of iterations of the diffusion.private int[]
kExtents
Dimensionality of the kernel.private float
kValue
Controls the diffusion rate.private float[]
levelImage
DOCUMENT ME!private float[]
outputBuffer
Stores result of AlgorithmConvolverprivate 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 AlgorithmFastMarching(ModelImage srcImg, float[] sigmas, int iter, float kValue)
AnisotropicDiffusion.
-
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
calc2D()
calc2D - calculates the diffused image and creates the new VOI for the original image.private void
calc3D()
calc3D - calculates the diffused image and creates the new VOI for the original image.void
cleanUp()
DOCUMENT ME!void
finalize()
finalize - sets class storages arrays to null so that System.gc() can free the memory.private float
getBiLinear(float[] imageBuffer, int xDim, float x, float y)
getBiLinear - version of get that performs bi-linear interpoloation.private float
getTriLinear(float[] imageBuffer, int xDim, int imageSliceSize, float x, float y, float z)
getTriLinear - version of get that performs trilinear interpoloation.private void
makeKernels2D()
makeKernals2D - creates the derivative kernels used to calculate the gradient magnitude and kernel for the diffusion process.private void
makeKernels3D()
makeKernals3D - creates the derivative kernels used to calculate the gradient magnitude and kernel for the diffusion process.void
runAlgorithm()
Starts the algorithm.-
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
-
edgeImage
private float[] edgeImage
DOCUMENT ME!
-
GxData
private float[] GxData
Storage location of the first derivative of the Gaussian in the X direction.
-
GyData
private float[] GyData
Storage location of the first derivative of the Gaussian in the Y direction.
-
GzData
private float[] GzData
Storage location of the first derivative of the Gaussian in the Z direction.
-
iterations
private int iterations
Number of iterations of the diffusion.
-
kExtents
private int[] kExtents
Dimensionality of the kernel.
-
kValue
private float kValue
Controls the diffusion rate. A large value causes this algorithms to act like gaussian smoothing and therefore diffuses across edges. K = small reduces blur across edges. Typical K = 10.
-
levelImage
private float[] levelImage
DOCUMENT ME!
-
sigmas
private float[] sigmas
Standard deviations of the gaussian used to calculate the kernels.
-
outputBuffer
private float[] outputBuffer
Stores result of AlgorithmConvolver
-
-
Constructor Detail
-
AlgorithmFastMarching
public AlgorithmFastMarching(ModelImage srcImg, float[] sigmas, int iter, float kValue)
AnisotropicDiffusion.- Parameters:
srcImg
- reference to the source imagesigmas
- sigmas used to describe the gaussian that is used in the calculation of the gradient magnitudeiter
- number of iterations (t) of the diffusion equationkValue
- K is a factor that controls the diffusion rate. A large value causes this algorithms to act like gaussian smoothing and therefore diffuses across edges. K = small reduces blur across edges. Typical K = 10;
-
-
Method Detail
-
cleanUp
public void cleanUp()
DOCUMENT ME!
-
finalize
public void finalize()
finalize - sets class storages arrays to null so that System.gc() can free the memory.- Overrides:
finalize
in classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()
Starts the algorithm.- Specified by:
runAlgorithm
in classAlgorithmBase
-
calc2D
private void calc2D()
calc2D - calculates the diffused image and creates the new VOI for the original image.
-
calc3D
private void calc3D()
calc3D - calculates the diffused image and creates the new VOI for the original image.
-
getBiLinear
private float getBiLinear(float[] imageBuffer, int xDim, float x, float y)
getBiLinear - version of get that performs bi-linear interpoloation. Note - does NOT perform bounds checking- Parameters:
imageBuffer
- buffer containing pixel dataxDim
- x dimension offsetx
- x coordinatey
- y coordinate- Returns:
- DOCUMENT ME!
-
getTriLinear
private float getTriLinear(float[] imageBuffer, int xDim, int imageSliceSize, float x, float y, float z)
getTriLinear - version of get that performs trilinear interpoloation.- Parameters:
imageBuffer
- buffer containing pixel dataxDim
- x dimension offsetimageSliceSize
- DOCUMENT ME!x
- x coordinatey
- y coordinatez
- z coordinate- Returns:
- DOCUMENT ME!
-
makeKernels2D
private void makeKernels2D()
makeKernals2D - creates the derivative kernels used to calculate the gradient magnitude and kernel for the diffusion process.
-
makeKernels3D
private void makeKernels3D()
makeKernals3D - creates the derivative kernels used to calculate the gradient magnitude and kernel for the diffusion process.
-
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
-
-