Class AlgorithmImageMath
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.utilities.AlgorithmImageMath
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmImageMath extends AlgorithmBase
Algorithm that adds, subtracts, multiplies, or divides an image by some user specified value. In addition, the square root or log of an image can be calculated. If the new image exceeds the range that can be stored in an image of that type the data is either clipped and stored in the original image. Or a new image of a type (int, float...) that can store the range of new data is generated.- Version:
- 1.0 Dec 30, 1999
- Author:
- Matthew J. McAuliffe, Ph.D.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AlgorithmImageMath.Operator
-
Field Summary
Fields Modifier and Type Field Description static int
ABSOLUTE_VALUE
DOCUMENT ME!static int
ADD
DOCUMENT ME!static int
AVERAGE
DOCUMENT ME!static int
CLIP
DOCUMENT ME!private double
clipMax
Maximum clipping modes if data result value exceeds the capacity of image's data type.private double
clipMin
Minimum clipping modes if data result value exceeds the capacity of image's data type.private int
clipMode
Clipping mode.static int
CONSTANT
DOCUMENT ME!static int
CONVERT_FLOAT
DOCUMENT ME!static int
DIVIDE
DOCUMENT ME!private boolean
entireImage
Flag, if true, indicates that the whole image should be processed.static int
INVERSE
DOCUMENT ME!static int
LOG
DOCUMENT ME!private double
max
Used to store the image maximum.private double
maxB
private double
maxG
private double
maxR
private double
min
Used to store the image minimum.private double
minB
private double
minG
private double
minR
static int
MULTIPLY
DOCUMENT ME!private AlgorithmImageMath.Operator
opType
Operation to be performed on the images (i.e.static int
PROMOTE
DOCUMENT ME!static int
SQUARE
DOCUMENT ME!static int
SQUARE_ROOT
DOCUMENT ME!static int
SUBTRACT
DOCUMENT ME!static int
SUM
DOCUMENT ME!private boolean
useComplex
DOCUMENT ME!private double
value
the value to modify the image with.private double
valueB
private double
valueI
imaginary part of value to modify complex or dcomplex image with or green color of color 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 AlgorithmImageMath(ModelImage srcImg, int type, double val, double valI, double valB, int _clipMode, boolean maskFlag)
Creates a new AlgorithmImageMath object.AlgorithmImageMath(ModelImage destImg, ModelImage srcImg, int type, double val, double valI, double valB, int _clipMode, boolean maskFlag)
Creates a new AlgorithmImageMath object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
calcInPlace()
Generates the new data and places in the source image.private void
calcInPlaceColor()
private void
calcInPlaceComplex()
Generates the new data and places in the source image.private void
calcStoreInDest()
Generates the new data and places in a new (destination) image.private void
calcStoreInDestColor()
private void
calcStoreInDestComplex()
Generates the new data and places in a new (destination) image.void
finalize()
Prepares this class for destruction.private int
findType(int stType)
Find the type able to contain the full range of the data.private int
promoteType(int presentType)
DOCUMENT ME!void
runAlgorithm()
Starts the program.private void
setClipValues()
Sets clipMin and clipMax.private boolean
testType(int type, double minVal, double maxVal)
Determine if the min and max values are in the image types range.-
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
-
ABSOLUTE_VALUE
public static final int ABSOLUTE_VALUE
DOCUMENT ME!- See Also:
- Constant Field Values
-
ADD
public static final int ADD
DOCUMENT ME!- See Also:
- Constant Field Values
-
AVERAGE
public static final int AVERAGE
DOCUMENT ME!- See Also:
- Constant Field Values
-
CONSTANT
public static final int CONSTANT
DOCUMENT ME!- See Also:
- Constant Field Values
-
DIVIDE
public static final int DIVIDE
DOCUMENT ME!- See Also:
- Constant Field Values
-
LOG
public static final int LOG
DOCUMENT ME!- See Also:
- Constant Field Values
-
MULTIPLY
public static final int MULTIPLY
DOCUMENT ME!- See Also:
- Constant Field Values
-
SQUARE
public static final int SQUARE
DOCUMENT ME!- See Also:
- Constant Field Values
-
SQUARE_ROOT
public static final int SQUARE_ROOT
DOCUMENT ME!- See Also:
- Constant Field Values
-
SUBTRACT
public static final int SUBTRACT
DOCUMENT ME!- See Also:
- Constant Field Values
-
SUM
public static final int SUM
DOCUMENT ME!- See Also:
- Constant Field Values
-
INVERSE
public static final int INVERSE
DOCUMENT ME!- See Also:
- Constant Field Values
-
CLIP
public static final int CLIP
DOCUMENT ME!- See Also:
- Constant Field Values
-
PROMOTE
public static final int PROMOTE
DOCUMENT ME!- See Also:
- Constant Field Values
-
CONVERT_FLOAT
public static final int CONVERT_FLOAT
DOCUMENT ME!- See Also:
- Constant Field Values
-
clipMax
private double clipMax
Maximum clipping modes if data result value exceeds the capacity of image's data type.
-
clipMin
private double clipMin
Minimum clipping modes if data result value exceeds the capacity of image's data type.
-
clipMode
private int clipMode
Clipping mode.CLIP = 0; clamp result data to the bounds of the input image type PROMOTE = 1; promote image type so that the range of the result fits into the new image type. ( ie. byte to short). FLOAT = 2; Convert image to float
-
entireImage
private boolean entireImage
Flag, if true, indicates that the whole image should be processed. If false, process the image over the mask areas.
-
max
private double max
Used to store the image maximum.
-
min
private double min
Used to store the image minimum.
-
minR
private double minR
-
maxR
private double maxR
-
minG
private double minG
-
maxG
private double maxG
-
minB
private double minB
-
maxB
private double maxB
-
opType
private AlgorithmImageMath.Operator opType
Operation to be performed on the images (i.e. Add, ...)
-
useComplex
private boolean useComplex
DOCUMENT ME!
-
value
private double value
the value to modify the image with.
-
valueI
private double valueI
imaginary part of value to modify complex or dcomplex image with or green color of color image.
-
valueB
private double valueB
-
-
Constructor Detail
-
AlgorithmImageMath
public AlgorithmImageMath(ModelImage srcImg, int type, double val, double valI, double valB, int _clipMode, boolean maskFlag)
Creates a new AlgorithmImageMath object.- Parameters:
srcImg
- source image modeltype
- operation type to be performed on the imageval
- value applied to the imagevalI
- imaginary part of value applied if image is of complex type or green part of color if color imagevalB
- blue part of color image_clipMode
- clamp data to image type range or promote image type to hold new data range.maskFlag
- Flag that indicates that the operator will be calculated for the whole image if equal to true
-
AlgorithmImageMath
public AlgorithmImageMath(ModelImage destImg, ModelImage srcImg, int type, double val, double valI, double valB, int _clipMode, boolean maskFlag)
Creates a new AlgorithmImageMath object.- Parameters:
destImg
- image model where result image is to storedsrcImg
- source image modeltype
- operation type to be performed on the imageval
- value applied to the imagevalI
- imaginary part of value applied if image is of complex type or green part of color if color imagevalB
- blue part of color image_clipMode
- clamp data to image type range or promote image type to hold new data range.maskFlag
- Flag that indicates that the operator will be calculated for the whole image if equal to true
-
-
Method Detail
-
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
-
calcInPlaceColor
private void calcInPlaceColor()
-
calcInPlace
private void calcInPlace()
Generates the new data and places in the source image.note that if this method is canceled part-way through a multi-sliced image, it will almost certainly be partially adjusted. This is because to save memory buffer-space, it returns an adjusted slice back to the source image after processing it; it then takes out the next slice to alter it. Canceling a job causes the current slice will not be affected, but all previous slices will be.
-
calcInPlaceComplex
private void calcInPlaceComplex()
Generates the new data and places in the source image.note that if this method is canceled part-way through a multi-sliced image, it will almost certainly be partially adjusted. This is because to save memory buffer-space, it returns an adjusted slice back to the source image after processing it; it then takes out the next slice to alter it. Canceling a job causes the current slice will not be affected, but all previous slices will be.
-
calcStoreInDestColor
private void calcStoreInDestColor()
-
calcStoreInDest
private void calcStoreInDest()
Generates the new data and places in a new (destination) image.This method checks for thread halting actions more infrequently than the in-place method.
-
calcStoreInDestComplex
private void calcStoreInDestComplex()
Generates the new data and places in a new (destination) image.
-
findType
private int findType(int stType)
Find the type able to contain the full range of the data.- Parameters:
stType
- starting type of image. Image will be promoted above this type if needed.- Returns:
- type capable of storing full range of data. See ModelStorageBase for image types.
-
promoteType
private int promoteType(int presentType)
DOCUMENT ME!- Parameters:
presentType
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
setClipValues
private void setClipValues()
Sets clipMin and clipMax.
-
testType
private boolean testType(int type, double minVal, double maxVal)
Determine if the min and max values are in the image types range.- Parameters:
type
- image typeminVal
- min value of the imagemaxVal
- max value of the image- Returns:
- true if min and max are within the image type specified
-
-