Class AlgorithmGradientMagnitude
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.filters.AlgorithmGradientMagnitude
-
- All Implemented Interfaces:
AlgorithmInterface
,java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmGradientMagnitude extends AlgorithmBase implements AlgorithmInterface
Calculates the gradient magnitude of an image at a scale defined by the user.- Version:
- 0.1 Feb 11, 1998
- Author:
- Matthew J. McAuliffe, Ph.D.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
blue
DOCUMENT ME!private boolean
entireImage
Flag, if true, indicates that the whole image should be processed.private boolean
green
DOCUMENT ME!private float[]
Gx2Data
Storage location of the first derivative of the Gaussian in the X direction for 2D images;private float[]
GxData
Storage location of the first derivative of the Gaussian in the X direction.private float[]
Gy2Data
Storage location of the first derivative of the Gaussian in the Y direction for 2D images;private float[]
GyData
Storage location of the first derivative of the Gaussian in the Y direction.private float[]
GzData
Storage location of the first derivative of the Gaussian in the Z direction.private int[]
kExtents
Extents of the kernel.private float[]
outputBuffer
Receives output of AlgorithmConvolverprivate boolean
red
Flags indicate which color channel to process.private float[]
sigmas
Standard deviations of the gaussian used to calculate the kernels.-
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 AlgorithmGradientMagnitude(ModelImage srcImg, float[] sigmas, boolean maskFlag, boolean img25D)
Creates a new AlgorithmGradientMagnitude object.AlgorithmGradientMagnitude(ModelImage destImg, ModelImage srcImg, float[] sigmas, boolean maskFlag, boolean img25D)
Creates a new AlgorithmGradientMagnitude object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
algorithmPerformed(AlgorithmBase algorithm)
Called after an algorithm this listener is registered to exits (maybe successfully, maybe not).float[]
calcInBuffer2D(float[] buffer, int[] extents, boolean color, float[] xDirs, float[] yDirs)
Calculates the gradient magnitude of a 2D image and returns it as a float buffer.float[]
calcInBuffer2DUnnormalized(float[] buffer, int[] extents, boolean color, float[] xDirs, float[] yDirs)
Calculates the gradient magnitude of a 2D image and returns it as a float buffer.private void
calcInPlace2D(int nImages)
Calculates the gradient image and replaces the source image with the new image.private float[]
calcInPlace2DBuffer(int nImages, float[] buffer, int[] extents, boolean color, float[] xDirections, float[] yDirections)
Calculates the gradient image and returns a float buffer with the new values.private float[]
calcInPlace2DBufferUnnormalized(int nImages, float[] buffer, int[] extents, boolean color, float[] xDirections, float[] yDirections)
Calculates the gradient image and returns a float buffer with the new values.private void
calcInPlace34D()
Calculates the gradient magnitude image and replaces the source image with the new image.private void
calcStoreInDest2D(int nImages)
This function produces the gradient magnitude of input image.private void
calcStoreInDest34D()
This function produces the gradient magnitude of input image.void
finalize()
Prepares this class for destruction.private void
makeKernels2D()
Creates Gaussian derivative kernels.private void
makeKernels3D()
Creates Gaussian derivative kernels.void
runAlgorithm()
Starts the program.void
setBlue(boolean flag)
Sets the flag for the blue channel.void
setGreen(boolean flag)
Sets the flag for the green channel.void
setRed(boolean flag)
Sets the flag for the red channel.-
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
-
blue
private boolean blue
DOCUMENT ME!
-
entireImage
private boolean entireImage
Flag, if true, indicates that the whole image should be processed. If false only process the image over the mask areas.
-
green
private boolean green
DOCUMENT ME!
-
Gx2Data
private float[] Gx2Data
Storage location of the first derivative of the Gaussian in the X direction for 2D images;
-
GxData
private float[] GxData
Storage location of the first derivative of the Gaussian in the X direction.
-
Gy2Data
private float[] Gy2Data
Storage location of the first derivative of the Gaussian in the Y direction for 2D images;
-
GyData
private float[] GyData
Storage location of the first derivative of the Gaussian in the Y direction.
-
GzData
private float[] GzData
Storage location of the first derivative of the Gaussian in the Z direction.
-
kExtents
private int[] kExtents
Extents of the kernel.
-
red
private boolean red
Flags indicate which color channel to process. True indicates the channel should be processed.
-
sigmas
private float[] sigmas
Standard deviations of the gaussian used to calculate the kernels.
-
outputBuffer
private float[] outputBuffer
Receives output of AlgorithmConvolver
-
-
Constructor Detail
-
AlgorithmGradientMagnitude
public AlgorithmGradientMagnitude(ModelImage srcImg, float[] sigmas, boolean maskFlag, boolean img25D)
Creates a new AlgorithmGradientMagnitude object.- Parameters:
srcImg
- source image modelsigmas
- Gaussian standard deviations in each dimensionmaskFlag
- Flag, if true, indicates that the gradient magnitude will be calculated for the whole imageimg25D
- Flag, if true, indicates that each slice of the 3D volume should be processed independently. 2D images disregard this flag.
-
AlgorithmGradientMagnitude
public AlgorithmGradientMagnitude(ModelImage destImg, ModelImage srcImg, float[] sigmas, boolean maskFlag, boolean img25D)
Creates a new AlgorithmGradientMagnitude object.- Parameters:
destImg
- image model where result image is to storedsrcImg
- source image modelsigmas
- Gaussian standard deviations in each dimensionmaskFlag
- Flag, if true, indicates that the gradient magnitude will be calculated for the whole imageimg25D
- Flag, if true, indicates that each slice of the 3D volume should be processed independently. 2D images disregard this flag.
-
-
Method Detail
-
calcInBuffer2D
public float[] calcInBuffer2D(float[] buffer, int[] extents, boolean color, float[] xDirs, float[] yDirs)
Calculates the gradient magnitude of a 2D image and returns it as a float buffer.- Parameters:
buffer
- DOCUMENT ME!extents
- DOCUMENT ME!color
- DOCUMENT ME!xDirs
- DOCUMENT ME!yDirs
- DOCUMENT ME!- Returns:
- Buffer with the gradient magnitude of the image.
-
calcInBuffer2DUnnormalized
public float[] calcInBuffer2DUnnormalized(float[] buffer, int[] extents, boolean color, float[] xDirs, float[] yDirs)
Calculates the gradient magnitude of a 2D image and returns it as a float buffer.- Parameters:
buffer
- DOCUMENT ME!extents
- DOCUMENT ME!color
- DOCUMENT ME!xDirs
- DOCUMENT ME!yDirs
- DOCUMENT ME!- Returns:
- Buffer with the gradient magnitude of the image.
-
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
-
setBlue
public void setBlue(boolean flag)
Sets the flag for the blue channel.- Parameters:
flag
- if set to true then the blue channel is processed.
-
setGreen
public void setGreen(boolean flag)
Sets the flag for the green channel.- Parameters:
flag
- if set to true then the green channel is processed.
-
setRed
public void setRed(boolean flag)
Sets the flag for the red channel.- Parameters:
flag
- if set to true then the red channel is processed.
-
calcInPlace2D
private void calcInPlace2D(int nImages)
Calculates the gradient image and replaces the source image with the new image.- Parameters:
nImages
- number of images on which to calculate the gradient magnitude. If 2D image then nImage = 1. If 3D image where each image is to processed independently then nImages equals the number of images in the volume.
-
calcInPlace2DBuffer
private float[] calcInPlace2DBuffer(int nImages, float[] buffer, int[] extents, boolean color, float[] xDirections, float[] yDirections)
Calculates the gradient image and returns a float buffer with the new values.- Parameters:
nImages
- number of images on which to calculate the gradient magnitude. If 2D image then nImage = 1. If 3D image where each image is to processed independently then nImages equals the number of images in the volume.buffer
- DOCUMENT ME!extents
- DOCUMENT ME!color
- DOCUMENT ME!xDirections
- DOCUMENT ME!yDirections
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
calcInPlace2DBufferUnnormalized
private float[] calcInPlace2DBufferUnnormalized(int nImages, float[] buffer, int[] extents, boolean color, float[] xDirections, float[] yDirections)
Calculates the gradient image and returns a float buffer with the new values.- Parameters:
nImages
- number of images on which to calculate the gradient magnitude. If 2D image then nImage = 1. If 3D image where each image is to processed independently then nImages equals the number of images in the volume.buffer
- DOCUMENT ME!extents
- DOCUMENT ME!color
- DOCUMENT ME!xDirections
- DOCUMENT ME!yDirections
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
calcInPlace34D
private void calcInPlace34D()
Calculates the gradient magnitude image and replaces the source image with the new image.
-
calcStoreInDest2D
private void calcStoreInDest2D(int nImages)
This function produces the gradient magnitude of input image.- Parameters:
nImages
- number of images on which to calculate the gradient magnitude. If 2D image then nImage = 1. If 3D image where each image is to processed independently then nImages equals the number of images in the volume.
-
calcStoreInDest34D
private void calcStoreInDest34D()
This function produces the gradient magnitude of input image.
-
makeKernels2D
private void makeKernels2D()
Creates Gaussian derivative kernels.
-
makeKernels3D
private void makeKernels3D()
Creates Gaussian derivative kernels.
-
algorithmPerformed
public void algorithmPerformed(AlgorithmBase algorithm)
Description copied from interface:AlgorithmInterface
Called after an algorithm this listener is registered to exits (maybe successfully, maybe not). If the algorithm is run in a separate thread, this call will be made within that thread. If not, this call will be made from that same, shared thread.- Specified by:
algorithmPerformed
in interfaceAlgorithmInterface
- Parameters:
algorithm
- the algorithm which has just completed
-
-