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:
ActionListener,WindowListener,Runnable,EventListener
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanFlags to indicate which color channels to process.private intBuffer size adjustment for color images.private booleanFlag to indicate if the source image is color.(package private) intprivate booleanWhether to convolve the whole image or just pixels inside a mask.private booleanFlags to indicate which color channels to process.private int[]The dimensions of the both source and destination images.(package private) intprivate double[]Holds the original image data.private boolean[]Holds the original image mask data.private float[][]private int[]The dimensions of the kernel.private double[]Holds the result image data.private booleanFlags 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, threadStoppedFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionAlgorithmSeparableConvolver(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
Modifier and TypeMethodDescriptionvoidvoidprivate voidconvolve(double[] imageBuffer, float[] kernelBuffer, double[] resultBuffer) Perform one-dimension convolution.private voidconvolveNoColor(double[] imageBuffer, float[] kernelBuffer, double[] resultBuffer, boolean[] maskBuffer) Perform one-dimension convolution.private voidconvolveX(int from, int to) private voidconvolveY(int from, int to) private voidconvolveZ(int from, int to) voidexecute()voidfinalize()Prepares this class for destruction.float[]voidperform()Begins the excution of the 3D convolver.voidvoidStarts the convolution of the source image with the provided kernel.voidsetColorChannels(boolean _red, boolean _green, boolean _blue) Sets what color channels to convolve and tells the convolver that it is working on a color image.voidSets 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, 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
-
cFactor
private int cFactorBuffer size adjustment for color images. -
colorImage
private boolean colorImageFlag to indicate if the source image is color. -
curPercent
int curPercent -
incIndex
int incIndex -
outputBuffer
private double[] outputBufferHolds the result image data. -
entireImage
private boolean entireImageWhether to convolve the whole image or just pixels inside a mask. -
inputBuffer
private double[] inputBufferHolds the original image data. -
inputMask
private boolean[] inputMaskHolds the original image mask data. -
imgExtents
private int[] imgExtentsThe dimensions of the both source and destination images. -
kernelExtents
private int[] kernelExtentsThe dimensions of the kernel. -
kernelBuffer
private float[][] kernelBuffer -
red
private boolean redFlags to indicate which color channels to process. -
green
private boolean greenFlags to indicate which color channels to process. -
blue
private boolean blueFlags to indicate which color channels to process.
-
-
Constructor Details
-
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 Details
-
finalize
public void finalize()Prepares this class for destruction.- Overrides:
finalizein 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:
runAlgorithmin 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
Sets the mask to convolve within.- Overrides:
setMaskin classAlgorithmBase- Parameters:
newMask- mask to convolve within
-
getOutputBuffer
public float[] getOutputBuffer()
-