Class AlgorithmRemoveSlices
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.utilities.AlgorithmRemoveSlices
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmRemoveSlices extends AlgorithmBase
Algorithm verifies the z-th slice should be in included in the destination image, as defined in the list, remove. It copies the slice from the srcImage img to a buffer, and then from the buffer into the destination img. Copies the srcImage file info to a buffer and makes it conform to the new img, then copies it into the destImage file.Note that an image is a set of slices; each slice is XxY, with Z slices.**(as of 1 Nov, does not yet process the more complicated DICOM images Completely)
- Version:
- v0.11 1 Nov 1999 (processes most images)
- Author:
- David Parsons (parsonsd@cbel.cit.nih.gov) (with vast help from M.McAuliffe)
- See Also:
JDialogRemoveSlices
-
-
Field Summary
Fields Modifier and Type Field Description private int
oldZdim
Original Z dimension of the image.private boolean[]
remove
List of slices to remove from source image.private int
sliceArea
Area of a slice (Xdim * Ydim).private int
Xdim
X dimension of the image.private int
Ydim
Y dimension of the image.-
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 AlgorithmRemoveSlices(ModelImage srcImage, ModelImage destImage, boolean[] removeSlices)
Import source and destination images into the class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
calcInPlace()
Calculates the final output and stores it in the source image.void
calcStoreInDest()
Calculates the final output and puts it in a destination image.private int[]
computeNewExtents()
Calculates and returns the new extents based on the source image and the list of slices to be removed.void
finalize()
Prepares this class for destruction.protected int
getAxisOfChange()
Calculates and returns the axis of change based on the srcImage.protected int
getColorFactor()
Calculates and returns the color factor based on the srcImage.private int
getNumRemoved()
computes and returns the number of slices to remove.private int
getOffset(int ndims, int[] extents, int colorFactor, int t)
Calculate and return the offset for the given image and time slice.private int
getOffset(ModelImage img, int colorFactor, int t)
Calculate and return the offset for the given image and time slice.private FileInfoBase
getSliceFileInfo(int srcSlice, int destSlice, int t, int[] newExtents)
Build and return the fileInfo for the current slice based on the source slice, the destination slice and time slice.void
runAlgorithm()
Calculates the final output.static void
updateFileInfo(ModelImage image, ModelImage resultImage)
Copy important file information to resultant image structure.-
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
-
oldZdim
private int oldZdim
Original Z dimension of the image.
-
remove
private boolean[] remove
List of slices to remove from source image.
-
sliceArea
private int sliceArea
Area of a slice (Xdim * Ydim).
-
Xdim
private int Xdim
X dimension of the image.
-
Ydim
private int Ydim
Y dimension of the image.
-
-
Constructor Detail
-
AlgorithmRemoveSlices
public AlgorithmRemoveSlices(ModelImage srcImage, ModelImage destImage, boolean[] removeSlices)
Import source and destination images into the class.- Parameters:
srcImage
- source image (image to clip from)destImage
- destination image (image to paste to)removeSlices
- list of boolean indicating which slices in source should *not* be in the destination
-
-
Method Detail
-
updateFileInfo
public static void updateFileInfo(ModelImage image, ModelImage resultImage)
Copy important file information to resultant image structure.- Parameters:
image
- Source image.resultImage
- Resultant image.
-
calcInPlace
public void calcInPlace()
Calculates the final output and stores it in the source image.
-
calcStoreInDest
public void calcStoreInDest()
Calculates the final output and puts it in a destination image.
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()
Calculates the final output.- Specified by:
runAlgorithm
in classAlgorithmBase
-
getAxisOfChange
protected int getAxisOfChange() throws java.lang.Exception
Calculates and returns the axis of change based on the srcImage. The default (for most images) is 2. DICOM images need to be checked.- Returns:
- DOCUMENT ME!
- Throws:
java.lang.Exception
- DOCUMENT ME!
-
getColorFactor
protected int getColorFactor()
Calculates and returns the color factor based on the srcImage.- Returns:
- DOCUMENT ME!
-
computeNewExtents
private int[] computeNewExtents()
Calculates and returns the new extents based on the source image and the list of slices to be removed.- Returns:
- DOCUMENT ME!
-
getNumRemoved
private int getNumRemoved()
computes and returns the number of slices to remove.- Returns:
- DOCUMENT ME!
-
getOffset
private int getOffset(ModelImage img, int colorFactor, int t)
Calculate and return the offset for the given image and time slice.- Parameters:
img
- -- ModelImage whose offset is being computedcolorFactor
- -- the image's colorFactort
- -- current time slice- Returns:
- -- the computed offset into the data buffer
-
getOffset
private int getOffset(int ndims, int[] extents, int colorFactor, int t)
Calculate and return the offset for the given image and time slice.- Parameters:
ndims
- -- number of dimensionsextents
- -- the extents for the image offsetcolorFactor
- -- the image's colorFactort
- -- current time slice- Returns:
- -- the computed offset into the data buffer
-
getSliceFileInfo
private FileInfoBase getSliceFileInfo(int srcSlice, int destSlice, int t, int[] newExtents)
Build and return the fileInfo for the current slice based on the source slice, the destination slice and time slice.- Parameters:
srcSlice
- the current slice index for the src imagedestSlice
- the current slice index for the result (dest) imaget
- current time slicenewExtents
- the extents for the result (dest) image- Returns:
- the fileInfo for destSlice
-
-