Package gov.nih.mipav.model.algorithms
Class AlgorithmVOISimplexOpt
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.AlgorithmVOISimplexOpt
-
- All Implemented Interfaces:
de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
,java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmVOISimplexOpt extends AlgorithmBase implements de.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
Perform Simplex Optimization on a VOI that has been propagated to a slice to find a transformation which will make an affine "fit" a structure which the VOI fit on the previous slice (used in RFASegTool when propagating liver segmentation VOIs). Minimize cost = -sum of Gradient magnitude under propagated ROI in match image- Version:
- 1.0 July, 2003
- Author:
- Evan McCreedy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
AlgorithmVOISimplexOpt.CostFunction
Class for specifying optimization function for the simplex opt algorithm.
-
Field Summary
Fields Modifier and Type Field Description protected float
baseVOIGradMagSum
The sum of the gradient magnitude along the polygon.protected int
costFunc
Which cost function to use (MINDIFF or MAXSUM).private int
currentSlice
The slice number the VOI is in.private AlgorithmVOISimplexOpt.CostFunction
func
protected float[]
gradMagBuf
The gradient magnitude of the slice.private ModelImage
image
The source image.protected VOIContour
inputGon
The polygon of the VOI we are fitting.static int
MAXSUM
Indicates that the maximum summation cost function should be used (this is the perferred cost function).static int
MINDIFF
Indicates that the minimum difference cost function should be used (MAXSUM is perferred).private float[]
sigmas
the kernel size to use in calculating the gradient magnitude image.private int
simplexDim
Size of the simplex vertex array (5 == tx, ty, rot, zoomx, zoomy).private float[]
sliceBuf
The image slice that holds the VOI we are working on.protected int
xDim
The slice size in the x dimension.protected int
yDim
The slice size in the y dimension.-
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 AlgorithmVOISimplexOpt(ModelImage image, float[] sigmas, int costFunc)
Set up the algorithm to perform optimizations on an image.AlgorithmVOISimplexOpt(ModelImage image, VOIContour inputGon, float[] sigmas, int costFunc)
Set up the algorithm to perform optimizations on an image.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
eval(double[] x)
void
finalize()
Prepares this class for destruction.int
getNumberOfVariables()
protected TransMatrix
getTransform(double[] x)
Converts a row of p into 3x3 transformation matrix.VOIContour
goOptimize(float[] sliceBuf, VOIContour inputGon)
Run the simplex opt algorithm on a polygon (VOI) in a slice of an image.void
runAlgorithm()
Run the algorithm on a polygon already specified through the constructor.private VOIContour
search()
Find the best fit for the VOI polygon we have loaded into this algorithm.void
setCurrentSlice(int currentSlice)
Specify the slice containing the VOI to optimize.void
setPolygon(VOIContour poly)
Spefify the VOI polygon to optimize.-
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
-
MINDIFF
public static final int MINDIFF
Indicates that the minimum difference cost function should be used (MAXSUM is perferred).- See Also:
- Constant Field Values
-
MAXSUM
public static final int MAXSUM
Indicates that the maximum summation cost function should be used (this is the perferred cost function).- See Also:
- Constant Field Values
-
baseVOIGradMagSum
protected float baseVOIGradMagSum
The sum of the gradient magnitude along the polygon.
-
costFunc
protected int costFunc
Which cost function to use (MINDIFF or MAXSUM).
-
currentSlice
private int currentSlice
The slice number the VOI is in.
-
gradMagBuf
protected float[] gradMagBuf
The gradient magnitude of the slice.
-
image
private ModelImage image
The source image.
-
inputGon
protected VOIContour inputGon
The polygon of the VOI we are fitting.
-
sigmas
private float[] sigmas
the kernel size to use in calculating the gradient magnitude image.
-
simplexDim
private int simplexDim
Size of the simplex vertex array (5 == tx, ty, rot, zoomx, zoomy).
-
sliceBuf
private float[] sliceBuf
The image slice that holds the VOI we are working on.
-
xDim
protected int xDim
The slice size in the x dimension.
-
yDim
protected int yDim
The slice size in the y dimension.
-
func
private AlgorithmVOISimplexOpt.CostFunction func
-
-
Constructor Detail
-
AlgorithmVOISimplexOpt
public AlgorithmVOISimplexOpt(ModelImage image, float[] sigmas, int costFunc)
Set up the algorithm to perform optimizations on an image. The individual Polygons to optimize will be provided later (usegoOptimize()
)- Parameters:
image
- the image containing the VOI(s) to run the SimplexOpt algorithm onsigmas
- the kernel size to use in calculating the gradient magnitude imagecostFunc
- which cost function to use (MINDIFF or MAXSUM)
-
AlgorithmVOISimplexOpt
public AlgorithmVOISimplexOpt(ModelImage image, VOIContour inputGon, float[] sigmas, int costFunc)
Set up the algorithm to perform optimizations on an image. To be used in conjunction with therun
method.- Parameters:
image
- the image containing the VOI(s) to run the SimplexOpt algorithm oninputGon
- the Polygon to optimize the fit ofsigmas
- the kernel size to use in calculating the gradient magnitude imagecostFunc
- which cost function to use (MINDIFF or MAXSUM)
-
-
Method Detail
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
goOptimize
public VOIContour goOptimize(float[] sliceBuf, VOIContour inputGon)
Run the simplex opt algorithm on a polygon (VOI) in a slice of an image.- Parameters:
sliceBuf
- the slice the polygon resides ininputGon
- the polygon to optimize the fit of- Returns:
- the optimized polygon
-
runAlgorithm
public void runAlgorithm()
Run the algorithm on a polygon already specified through the constructor.- Specified by:
runAlgorithm
in classAlgorithmBase
-
setCurrentSlice
public void setCurrentSlice(int currentSlice)
Specify the slice containing the VOI to optimize.- Parameters:
currentSlice
- the slice with the VOI to optimize
-
setPolygon
public void setPolygon(VOIContour poly)
Spefify the VOI polygon to optimize.- Parameters:
poly
- the polygon
-
getTransform
protected TransMatrix getTransform(double[] x)
Converts a row of p into 3x3 transformation matrix.- Parameters:
x
- row of p[][] (one of the simplex vertices)- Returns:
- the transformation matrix corresponding to
x
-
search
private VOIContour search()
Find the best fit for the VOI polygon we have loaded into this algorithm.- Returns:
- the optimized polygon
-
eval
public double eval(double[] x)
- Specified by:
eval
in interfacede.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
-
getNumberOfVariables
public int getNumberOfVariables()
- Specified by:
getNumberOfVariables
in interfacede.jtem.numericalMethods.calculus.function.RealFunctionOfSeveralVariables
-
-