Package gov.nih.mipav.model.algorithms
Class AlgorithmBSnake
java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.AlgorithmBSnake
- All Implemented Interfaces:
ActionListener,WindowListener,Runnable,EventListener
Snake-like algorithm derivative using BSplines. The algorithm is supplied a polygon (VOI - contour) and that polygon
is allowed to evolve to edge of the object generated by calculating the gradient magnitude (i.e. the energy function)
at scale define by the user. The user/programmer supplies the sigmas (scales) at which to calculate the gradient
magnitude. A large scale slows the snake and causes the snake to conform to large scale structure. A small sigma
value causes the snake to conform to the small scale structure is therefore more sensitive to noise. The
three-dimensional version is really a two-and-half dimensional algorithm where resultant contour in a slice is
projected into the adjacent slice and is used as an initialization to the evolution in the new slice.
- Version:
- 0.1 Feb 11, 1998
- Author:
- Matthew J. McAuliffe, Ph.D.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intMaximum number of snake iterations.private float[]Storage location of the first derivative of the Gaussian in the X direction.private float[]Storage location of the first derivative of the Gaussian in the Y direction.private float[]Storage location of the first derivative of the Gaussian in the Z direction.private int[]Dimensionality of the kernel.static final intPropagate the source VOI to slices above and below its current slice.static final intPropagate the source VOI to slices above its current slice in the volume.static final intPropagate the source VOI to slices below its current slice in the volume.static final intDo not propagate the source VOI to any slices (2D).private static final floatThe maximum ratio of change in the energy under the VOI after propagation.private intThe VOI propagation mode to use.private VOIThe resultant polygon and the evolution has completed.private float[]Standard deviations of the Gaussian used to calculate the kernels.private ModelImageSource image.private VOIThe initial VOI to initialize the evolution process.Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, threadStoppedFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionAlgorithmBSnake(ModelImage srcImg, float[] sigmas, int boundaryIterations, VOI srcVOI) Set up the snake algorithm so that it can be run. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcalc2D()Prepares the data and runs the algorithm for a 2D image.private voidcalc3D()Prepares the data and runs the algorithm for a 3D image.voidfinalize()Prepares this class for destruction.Accessor that returns the resultant VOI.private voidMakes 2D derivative kernels to be used in the calculation of the gradient magnitude.private voidMakes 3D derivative kernels to be used in the calculation of the gradient magnitude.private voidpropDown(VOIContour resultContour, VOI resultVOI, float baseEnergy, int baseNPts) private voidpropUp(VOIContour resultContour, VOI resultVOI, float baseEnergy, int baseNPts) voidStarts the snake algorithm.private floatActual function that evolves the boundary.private floatActual function that evolves the boundary.private voidTakes the polygon and forms two special arrays for use in the Bspline.private voidTakes the polygon and forms two special arrays for use in the Bspline.voidsetPropagation(int type) Sets the propagation type.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, windowOpenedMethods 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, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
PROP_SINGLE
public static final int PROP_SINGLEDo not propagate the source VOI to any slices (2D).- See Also:
-
PROP_NEXT
public static final int PROP_NEXTPropagate the source VOI to slices above its current slice in the volume.- See Also:
-
PROP_PREV
public static final int PROP_PREVPropagate the source VOI to slices below its current slice in the volume.- See Also:
-
PROP_ALL
public static final int PROP_ALLPropagate the source VOI to slices above and below its current slice.- See Also:
-
PROP_THRESHOLD
private static final float PROP_THRESHOLDThe maximum ratio of change in the energy under the VOI after propagation.- See Also:
-
boundaryIterations
private int boundaryIterationsMaximum number of snake iterations. -
GxData
private float[] GxDataStorage location of the first derivative of the Gaussian in the X direction. -
GyData
private float[] GyDataStorage location of the first derivative of the Gaussian in the Y direction. -
GzData
private float[] GzDataStorage location of the first derivative of the Gaussian in the Z direction. -
kExtents
private int[] kExtentsDimensionality of the kernel. -
propagationType
private int propagationTypeThe VOI propagation mode to use. -
resultVOI
The resultant polygon and the evolution has completed. -
sigmas
private float[] sigmasStandard deviations of the Gaussian used to calculate the kernels. -
srcImage
Source image. -
srcVOI
The initial VOI to initialize the evolution process.
-
-
Constructor Details
-
AlgorithmBSnake
Set up the snake algorithm so that it can be run.- Parameters:
srcImg- 2D or 3D source imagesigmas- describe the scale of the Gaussian in each dimensionboundaryIterations- maximum number of snake iterationssrcVOI- VOI that is to be evolved
-
-
Method Details
-
finalize
public void finalize()Prepares this class for destruction.- Overrides:
finalizein classAlgorithmBase
-
getResultVOI
Accessor that returns the resultant VOI.- Returns:
- resultant VOI that has localized to the boundaries of the object
-
runAlgorithm
public void runAlgorithm()Starts the snake algorithm.- Specified by:
runAlgorithmin classAlgorithmBase
-
setPropagation
public void setPropagation(int type) Sets the propagation type.- Parameters:
type- if PROP_ALL, result contour from a slice is propagated to the adjacent slice and used to initialize the snake algorithm for that slice. If PROP_NEXT, result contour from the original slice is propagated to the next slice and used to initialize the snake algorithm for that slice. If PROP_PREV, result contour from the original slice is propagated to the previous slice. If PROP_SINGLE, the snake algorithm stops after optimizing the boundary in the present slice.
-
calc2D
private void calc2D()Prepares the data and runs the algorithm for a 2D image. -
calc3D
private void calc3D()Prepares the data and runs the algorithm for a 3D image. -
makeKernels2D
private void makeKernels2D()Makes 2D derivative kernels to be used in the calculation of the gradient magnitude. -
makeKernels3D
private void makeKernels3D()Makes 3D derivative kernels to be used in the calculation of the gradient magnitude. -
propDown
-
propUp
-
runSnake
Actual function that evolves the boundary.- Parameters:
xPoints- x coordinates that describe the contouryPoints- y coordinates that describe the contourimage- image dataresultGon- resultant polygon- Returns:
- the sum of the energy along the boundary of the
resultGon
-
runSnake
private float runSnake(float[] xPoints, float[] yPoints, float[] zPoints, float[] image, VOIBase result) Actual function that evolves the boundary.- Parameters:
xPoints- x coordinates that describe the contouryPoints- y coordinates that describe the contourimage- image dataresultGon- resultant polygon- Returns:
- the sum of the energy along the boundary of the
resultGon
-
setPoints
Takes the polygon and forms two special arrays for use in the Bspline.- Parameters:
xPoints- storage location of array of x coord. pointsyPoints- storage location array of y coord. pointsgon- initial polygon
-
setPoints
Takes the polygon and forms two special arrays for use in the Bspline.- Parameters:
xPoints- storage location of array of x coord. pointsyPoints- storage location array of y coord. pointsgon- initial polygon
-