Class AlgorithmAddMargins
java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.utilities.AlgorithmAddMargins
- All Implemented Interfaces:
ActionListener,WindowListener,Runnable,EventListener
Algorithm to add or remove margins around the image. Margins are defined in the screen-space coordinates.
marginX is screen-space left,right.
marginY is screen-space top,bottom.
marginZ is screen-space front,back.
Margins may be positive to add to the image, or negative to crop the image.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate double[]private int[]marginT indicating the number of slices to be padded in time at the start and end of T dimensionprivate int[]marginX indicating the number of pixels to be padded on left and the right of X dimensionprivate int[]marginY indicating the number of pixels to be padded on top and the bottom of Y dimensionprivate int[]marginZ indicating the number of slices to be padded in front and the back of Z dimensionFields 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
ConstructorsConstructorDescriptionAlgorithmAddMargins(ModelImage srcImage, int[] x, int[] y, int[] z) Add or remove margins from the srcImage.AlgorithmAddMargins(ModelImage srcImage, ModelImage destImage, int[] x, int[] y, int[] z) Add or remove margins from the srcImage and store the results in the destImage. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidAdds image margins and stores result in destImage.private voidAdds image margins and stores result in srcImage Must use getSrcImage after running this routine.private float[]calculateNewOrigin(ModelImage srcImg, int[] margin) Calculates the origin values for the modified image, based on the current origin values and the added margins.voidfinalize()Prepares this class for destruction.Returns the source image.voidRuns the add image margins algorithm.voidsetPadValue(float[] value) Sets the value for the added margins, for either grayscale or color images.voidsetTMargins(int[] tMargin) Adds or removes margins in the 4th dimensions.private voidupdateFileInfo(ModelImage kRead, ModelImage kWrite) Updates the fileInfo values for the kWrite image, uses the fileInfo values from kRead.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, 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
-
marginX
private int[] marginXmarginX indicating the number of pixels to be padded on left and the right of X dimension -
marginY
private int[] marginYmarginY indicating the number of pixels to be padded on top and the bottom of Y dimension -
marginZ
private int[] marginZmarginZ indicating the number of slices to be padded in front and the back of Z dimension -
marginT
private int[] marginTmarginT indicating the number of slices to be padded in time at the start and end of T dimension -
marginColor
private double[] marginColor
-
-
Constructor Details
-
AlgorithmAddMargins
Add or remove margins from the srcImage and store the results in the destImage.- Parameters:
srcImage- original imagedestImage- output modified imagex- margin in the screen-space x-direction to add or remove [left,right]y- margin in the screen-space y-direction to add or remove [top,bottom]z- margin in the screen-space z-direction to add or remove [front,back]
-
AlgorithmAddMargins
Add or remove margins from the srcImage.- Parameters:
srcImage- original image modified by this algorithm.x- margin in the screen-space x-direction to add or remove [left,right]y- margin in the screen-space y-direction to add or remove [top,bottom]z- margin in the screen-space z-direction to add or remove [front,back]
-
-
Method Details
-
finalize
public void finalize()Prepares this class for destruction.- Overrides:
finalizein classAlgorithmBase
-
getSrcImage
Returns the source image.- Overrides:
getSrcImagein classAlgorithmBase- Returns:
- source image, may be modified.
-
runAlgorithm
public void runAlgorithm()Runs the add image margins algorithm.- Specified by:
runAlgorithmin classAlgorithmBase
-
setPadValue
public void setPadValue(float[] value) Sets the value for the added margins, for either grayscale or color images.- Parameters:
value- the image values to fill in the added margins.
-
setTMargins
public void setTMargins(int[] tMargin) Adds or removes margins in the 4th dimensions.- Parameters:
tMargin- margins in time to add or remove from the image.
-
calcStoreInDest
private void calcStoreInDest()Adds image margins and stores result in destImage. -
calcStoreInPlace
private void calcStoreInPlace()Adds image margins and stores result in srcImage Must use getSrcImage after running this routine. -
updateFileInfo
Updates the fileInfo values for the kWrite image, uses the fileInfo values from kRead.- Parameters:
kRead- image to read fileInfo values fromkWrite- image to write fileInfo values to.
-
calculateNewOrigin
Calculates the origin values for the modified image, based on the current origin values and the added margins.- Parameters:
srcImg- original imagemargin- margins added or removed from the image- Returns:
- new origins.
-