Package gov.nih.mipav.model.algorithms
Class AlgorithmCenterOfMass
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.AlgorithmCenterOfMass
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmCenterOfMass extends AlgorithmBase
This algorithm calculates the center of mass for 2D and 3D black and white images.- Version:
- 1.0 February 26, 2008
- Author:
- William Gandler
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
allowDataWindow
If true, allow data window outputprivate boolean
entireImage
Flag, if true, indicates that the whole image should be processed.private float[]
threshold
Array of two thresholds. threshold[0] = Minimum threshold, threshold[1] = Maximum threshold.double
xCOM
x coordinate for center of mass, normalized by image resolutiondouble
yCOM
y coordinate for center of mass, normalized by image resolutiondouble
zCOM
z coordinate for center of mass, normalized by image resolution, if srcImage is 2D = 0-
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 AlgorithmCenterOfMass(ModelImage srcImg, float[] threshold, boolean maskFlag)
Creates a new AlgorithmCenterOfMass object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
calcInPlace2D()
Calculate center of mass of 2D black and white image.private void
calcInPlace3D()
Calculate center of mass of 3D black and white image.void
finalize()
Prepares this class for destruction.double[]
getCenterOfMass()
Returns the computed center of mass.void
runAlgorithm()
Starts the program.void
setAllowDataWindow(boolean allowDataWindow)
-
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
-
entireImage
private boolean entireImage
Flag, if true, indicates that the whole image should be processed. If false on process the image over the mask areas.
-
threshold
private float[] threshold
Array of two thresholds. threshold[0] = Minimum threshold, threshold[1] = Maximum threshold.
-
allowDataWindow
private boolean allowDataWindow
If true, allow data window output
-
xCOM
public double xCOM
x coordinate for center of mass, normalized by image resolution
-
yCOM
public double yCOM
y coordinate for center of mass, normalized by image resolution
-
zCOM
public double zCOM
z coordinate for center of mass, normalized by image resolution, if srcImage is 2D = 0
-
-
Constructor Detail
-
AlgorithmCenterOfMass
public AlgorithmCenterOfMass(ModelImage srcImg, float[] threshold, boolean maskFlag)
Creates a new AlgorithmCenterOfMass object.- Parameters:
srcImg
- source image modelthreshold
- array of two thresholdsmaskFlag
- true indicates that the whole image should be processed
-
-
Method Detail
-
setAllowDataWindow
public void setAllowDataWindow(boolean allowDataWindow)
-
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
-
calcInPlace2D
private void calcInPlace2D()
Calculate center of mass of 2D black and white image.
-
calcInPlace3D
private void calcInPlace3D()
Calculate center of mass of 3D black and white image.
-
getCenterOfMass
public double[] getCenterOfMass()
Returns the computed center of mass. If algorithm is not completed: returns null. If 2D: returns {xCenter, yCenter, 0} If 3D: returns {xCenter, yCenter, zCenter}
-
-