Package gov.nih.mipav.model.algorithms
Class AlgorithmSeparableConvolver
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.AlgorithmSeparableConvolver
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmSeparableConvolver extends AlgorithmBase
Convolves an image with a separable (symmetric) kernel and returns the result. The Gaussian and its derivatives are separable.Faster than the regualar convolver -- reg 2D: n^d*m^d, sep 2D: d*n^d*m ; d = img dimension, n = img size, m = kern size -- but requires more memory -- ~2 times more for 2D, ~3 times for 3D (plus significant extra memory required for algorithms which use this class (2 or 3 times more, depending on the dimension)).
Also note that this convolver has a different interface which must be used than the static point convolution functions which most algorithms use from the AlgorithmConvolver.
Color and voi mask code not tested (although the voi code is pretty straight-forward).
- Author:
- Evan McCreedy
- See Also:
AlgorithmConvolver
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
blue
Flags to indicate which color channels to process.private int
cFactor
Buffer size adjustment for color images.private boolean
colorImage
Flag to indicate if the source image is color.(package private) int
curPercent
private boolean
entireImage
Whether to convolve the whole image or just pixels inside a mask.private boolean
green
Flags to indicate which color channels to process.private int[]
imgExtents
The dimensions of the both source and destination images.(package private) int
incIndex
private double[]
inputBuffer
Holds the original image data.private boolean[]
inputMask
Holds the original image mask data.private float[][]
kernelBuffer
private int[]
kernelExtents
The dimensions of the kernel.private double[]
outputBuffer
Holds the result image data.private boolean
red
Flags to indicate which color channels to process.-
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 AlgorithmSeparableConvolver(float[] srcBuffer, int[] iExtents, float[][] kernBuffer, boolean colorImage)
Sets destination, source, and kernel buffers.AlgorithmSeparableConvolver(float[] srcBuffer, int[] iExtents, float[] kernBuffers, int[] kExtents, boolean colorImage)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterExecute()
void
beforeExecute()
private void
convolve(double[] imageBuffer, float[] kernelBuffer, double[] resultBuffer)
Perform one-dimension convolution.private void
convolveNoColor(double[] imageBuffer, float[] kernelBuffer, double[] resultBuffer, boolean[] maskBuffer)
Perform one-dimension convolution.private void
convolveX(int from, int to)
private void
convolveY(int from, int to)
private void
convolveZ(int from, int to)
void
execute()
void
finalize()
Prepares this class for destruction.float[]
getOutputBuffer()
void
perform()
Begins the excution of the 3D convolver.void
performMT()
void
runAlgorithm()
Starts the convolution of the source image with the provided kernel.void
setColorChannels(boolean _red, boolean _green, boolean _blue)
Sets what color channels to convolve and tells the convolver that it is working on a color image.void
setMask(java.util.BitSet newMask)
Sets the mask to convolve within.-
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, 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
-
cFactor
private int cFactor
Buffer size adjustment for color images.
-
colorImage
private boolean colorImage
Flag to indicate if the source image is color.
-
curPercent
int curPercent
-
incIndex
int incIndex
-
outputBuffer
private double[] outputBuffer
Holds the result image data.
-
entireImage
private boolean entireImage
Whether to convolve the whole image or just pixels inside a mask.
-
inputBuffer
private double[] inputBuffer
Holds the original image data.
-
inputMask
private boolean[] inputMask
Holds the original image mask data.
-
imgExtents
private int[] imgExtents
The dimensions of the both source and destination images.
-
kernelExtents
private int[] kernelExtents
The dimensions of the kernel.
-
kernelBuffer
private float[][] kernelBuffer
-
red
private boolean red
Flags to indicate which color channels to process.
-
green
private boolean green
Flags to indicate which color channels to process.
-
blue
private boolean blue
Flags to indicate which color channels to process.
-
-
Constructor Detail
-
AlgorithmSeparableConvolver
public AlgorithmSeparableConvolver(float[] srcBuffer, int[] iExtents, float[][] kernBuffer, boolean colorImage)
Sets destination, source, and kernel buffers. Call run() to convolve image.- Parameters:
srcBuffer
- source image data bufferiExtents
- source and destination image dimensionskernBuffer
- kernel image data buffer (kernel must be symmetric)kExtents
- kernel dimensionscolor
- whether the image is colorminProgressValue
- the minimum progress value.maxProgressValue
- the maximum progress value.
-
AlgorithmSeparableConvolver
public AlgorithmSeparableConvolver(float[] srcBuffer, int[] iExtents, float[] kernBuffers, int[] kExtents, boolean colorImage)
-
-
Method Detail
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
convolve
private void convolve(double[] imageBuffer, float[] kernelBuffer, double[] resultBuffer)
Perform one-dimension convolution.- Parameters:
imageBuffer
-kernelBuffer
-resultBuffer
-
-
convolveNoColor
private void convolveNoColor(double[] imageBuffer, float[] kernelBuffer, double[] resultBuffer, boolean[] maskBuffer)
Perform one-dimension convolution.- Parameters:
imageBuffer
-kernelBuffer
-resultBuffer
-
-
performMT
public void performMT()
-
perform
public void perform()
Begins the excution of the 3D convolver.
-
convolveX
private void convolveX(int from, int to)
-
convolveY
private void convolveY(int from, int to)
-
convolveZ
private void convolveZ(int from, int to)
-
beforeExecute
public void beforeExecute()
-
execute
public void execute()
-
afterExecute
public void afterExecute()
-
runAlgorithm
public void runAlgorithm()
Starts the convolution of the source image with the provided kernel.- Specified by:
runAlgorithm
in classAlgorithmBase
-
setColorChannels
public void setColorChannels(boolean _red, boolean _green, boolean _blue)
Sets what color channels to convolve and tells the convolver that it is working on a color image.- Parameters:
_red
- process the red channel_green
- process the green channel_blue
- process the blue channel
-
setMask
public void setMask(java.util.BitSet newMask)
Sets the mask to convolve within.- Overrides:
setMask
in classAlgorithmBase
- Parameters:
newMask
- mask to convolve within
-
getOutputBuffer
public float[] getOutputBuffer()
-
-