Class AlgorithmAddMargins
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.utilities.AlgorithmAddMargins
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmAddMargins extends AlgorithmBase
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.
-
-
Field Summary
Fields Modifier and Type Field Description private double[]
marginColor
private int[]
marginT
marginT indicating the number of slices to be padded in time at the start and end of T dimensionprivate int[]
marginX
marginX indicating the number of pixels to be padded on left and the right of X dimensionprivate int[]
marginY
marginY indicating the number of pixels to be padded on top and the bottom of Y dimensionprivate int[]
marginZ
marginZ indicating the number of slices to be padded in front and the back of Z 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 AlgorithmAddMargins(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
calcStoreInDest()
Adds image margins and stores result in destImage.private void
calcStoreInPlace()
Adds 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.void
finalize()
Prepares this class for destruction.ModelImage
getSrcImage()
Returns the source image.void
runAlgorithm()
Runs the add image margins algorithm.void
setPadValue(float[] value)
Sets the value for the added margins, for either grayscale or color images.void
setTMargins(int[] tMargin)
Adds or removes margins in the 4th dimensions.private void
updateFileInfo(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, 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
-
marginX
private int[] marginX
marginX indicating the number of pixels to be padded on left and the right of X dimension
-
marginY
private int[] marginY
marginY indicating the number of pixels to be padded on top and the bottom of Y dimension
-
marginZ
private int[] marginZ
marginZ indicating the number of slices to be padded in front and the back of Z dimension
-
marginT
private int[] marginT
marginT indicating the number of slices to be padded in time at the start and end of T dimension
-
marginColor
private double[] marginColor
-
-
Constructor Detail
-
AlgorithmAddMargins
public 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.- 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
public AlgorithmAddMargins(ModelImage srcImage, int[] x, int[] y, int[] z)
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 Detail
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
getSrcImage
public ModelImage getSrcImage()
Returns the source image.- Overrides:
getSrcImage
in classAlgorithmBase
- Returns:
- source image, may be modified.
-
runAlgorithm
public void runAlgorithm()
Runs the add image margins algorithm.- Specified by:
runAlgorithm
in 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
private void updateFileInfo(ModelImage kRead, ModelImage kWrite)
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
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.- Parameters:
srcImg
- original imagemargin
- margins added or removed from the image- Returns:
- new origins.
-
-