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:
ActionListener,WindowListener,Runnable,EventListener
This algorithm calculates the center of mass for 2D and 3D black and white images.
- Version:
- 1.0 February 26, 2008
- Author:
- William Gandler
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanIf true, allow data window outputprivate booleanFlag, if true, indicates that the whole image should be processed.private float[]Array of two thresholds. threshold[0] = Minimum threshold, threshold[1] = Maximum threshold.doublex coordinate for center of mass, normalized by image resolutiondoubley coordinate for center of mass, normalized by image resolutiondoublez coordinate for center of mass, normalized by image resolution, if srcImage is 2D = 0Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStoppedFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionAlgorithmCenterOfMass(ModelImage srcImg, float[] threshold, boolean maskFlag) Creates a new AlgorithmCenterOfMass object. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidCalculate center of mass of 2D black and white image.private voidCalculate center of mass of 3D black and white image.voidfinalize()Prepares this class for destruction.double[]Returns the computed center of mass.voidStarts the program.voidsetAllowDataWindow(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, 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
-
entireImage
private boolean entireImageFlag, if true, indicates that the whole image should be processed. If false on process the image over the mask areas. -
threshold
private float[] thresholdArray of two thresholds. threshold[0] = Minimum threshold, threshold[1] = Maximum threshold. -
allowDataWindow
private boolean allowDataWindowIf true, allow data window output -
xCOM
public double xCOMx coordinate for center of mass, normalized by image resolution -
yCOM
public double yCOMy coordinate for center of mass, normalized by image resolution -
zCOM
public double zCOMz coordinate for center of mass, normalized by image resolution, if srcImage is 2D = 0
-
-
Constructor Details
-
AlgorithmCenterOfMass
Creates a new AlgorithmCenterOfMass object.- Parameters:
srcImg- source image modelthreshold- array of two thresholdsmaskFlag- true indicates that the whole image should be processed
-
-
Method Details
-
setAllowDataWindow
public void setAllowDataWindow(boolean allowDataWindow) -
finalize
public void finalize()Prepares this class for destruction.- Overrides:
finalizein classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()Starts the program.- Specified by:
runAlgorithmin 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}
-