Class AlgorithmNMSuppression
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.filters.AlgorithmNMSuppression
-
- All Implemented Interfaces:
AlgorithmInterface
,java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmNMSuppression extends AlgorithmBase implements AlgorithmInterface
Calculates the non-maximum suppression of an image at a scale defined by the user Edges are defined as the union of points for which the gradient magnitude assumes a maximum in the gradient direction. Introduce a local orthonormal coordinate system (u,v) at any point P0, where the v-axis is parallel to the gradient direction at P0, and the u-axis is perpindicular. Iu = sin(a)*Ix - cos(a)*Iy Iv = cos(a)*Ix + sin(a)*Iy cos(a) = Ix/(sqrt(Ix*Ix + Iy*Iy)) evaluated at P0 sin(a) = Iy/(sqrt(Ix*Ix + Iy*Iy)) evaluated at P0 Iu = (Ix*Iy - Ix*Iy)/(sqrt(Ix*Ix + Iy*Iy)) = 0 Iv = (Ix*Ix + Iy*Iy)/(sqrt(Ix*Ix + Iy*Iy)) = sqrt(Ix*Ix + Iy*Iy) Iv*Iv = Ix*Ix + Iy*Iy Ivv = (cos(a)*Ix + sin(a)*Iy)(cos(a)*Ix + sin(a)*Iy) = cos(a)*cos(a)*Ixx + 2*cos(a)*sin(a)*Ixy + sin(a)*sin(a)*Iyy = (Ix*Ix*Ixx + 2*Ix*Iy*Ixy + Iy*Iy*Iyy)/(Ix*Ix + Iy*Iy) Iv*Iv*Ivv = Ix*Ix*Ixx + 2*Ix*Iy*Ixy + Iy*Iy*Iyy Ivvv = (cos(a)*cos(a)*Ixx + 2*cos(a)*sin(a)*Ixy + sin(a)*sin(a)*Iyy)(cos(a)*Ix + sin(a)*Iy) = cos(a)*cos(a)*cos(a)*Ixxx + 3*cos(a)*cos(a)*sin(a)*Ixxy + 3*cos(a)*sin(a)*sin(a)*Ixyy + sin(a)*sin(a)*sin(a)*Iyyy = (Ix*Ix*Ix*Ixxx + 3*Ix*Ix*Iy*Ixxy + 3*Ix*Iy*Iy*Ixyy + Iy*Iy*Iy*Iyyy)/((Ix*Ix + Iy*Iy)**3/2) Iv*Iv*Iv*Ivvv = Ix*Ix*Ix*Ixxx + 3*Ix*Ix*Iy*Ixxy + 3*Ix*Iy*Iy*Ixyy + Iy*Iy*Iy*Iyyy Assuming that the second and third-order directional derivatives of I in the v-direction are not simultaneously zero, a necessary and sufficient condition for P0 to be a gradient maximum in the gradient direction may be stated as: Ivv = 0, Ivvv For 3D a similar derivation: Iv = cos(a)*sin(b)*Ix + sin(a)*sin(b)*Iy + cos(b)*Iz where spherical coordinates are being used cos(a) = Ix/(sqrt(Ix*Ix + Iy*Iy)) evaluated at P0 sin(a) = Iy/(sqrt(Ix*Ix + Iy*Iy)) evaluated at P0 cos(b) = Iz/(sqrt(Ix*Ix + Iy*Iy + Iz*Iz)) evaluated at P0 sin(b) = sqrt(Ix*Ix + Iy*Iy)/(sqrt(Ix*Ix + Iy*Iy + Iz*Iz)) evaluated at P0 Iv = (Ix*Ix + Iy*Iy + Iz*Iz)/(sqrt(Ix*Ix + Iy*Iy + Iz*Iz)) = sqrt(Ix*Ix + Iy*Iy + Iz*Iz) Iv*Iv = Ix*Ix + Iy*Iy + Iz*Iz Ivv = (cos(a)*sin(b)*Ix + sin(a)*sin(b)*Iy + cos(b)*Iz)(cos(a)*sin(b)*Ix + sin(a)*sin(b)*Iy + cos(b)*Iz) = cos(a)*cos(a)*sin(b)*sin(b)*Ixx + 2*cos(a)*sin(a)*sin(b)*sin(b)*Ixy + 2*cos(a)*cos(b)*sin(b)*Ixz + sin(a)*sin(a)*sin(b)*sin(b)*Iyy + 2*sin(a)*cos(b)*sin(b)*Iyz + cos(b)*cos(b)*Izz = (Ix*Ix*Ixx + 2*Ix*Iy*Ixy + 2*Ix*Iz*Ixz + Iy*Iy*Iyy + 2*Iy*Iz*Iyz + Iz*Iz*Izz)/ (Ix*Ix + Iy*Iy + Iz*Iz) Iv*Iv*Ivv =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ixyz + 3*Ix*Iz*Iz*Ixzz + Iy*Iy*Iy*Iyyy + 3*Iy*Iy*Iz*Iyyz + 3*Iy*Iz*Iz*Iyzz + Iz*Iz*Iz*Izzz
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
edgeImage
DOCUMENT ME!private boolean
entireImage
DOCUMENT ME!private float[]
GxData
DOCUMENT ME!private float[]
GxxData
DOCUMENT ME!private float[]
GxxxData
DOCUMENT ME!private float[]
GxxyData
DOCUMENT ME!private float[]
GxyData
DOCUMENT ME!private float[]
GxyyData
DOCUMENT ME!private float[]
GxzData
DOCUMENT ME!private float[]
GyData
DOCUMENT ME!private float[]
GyyData
DOCUMENT ME!private float[]
GyyyData
DOCUMENT ME!private float[]
GyzData
DOCUMENT ME!private float[]
GzData
DOCUMENT ME!private float[]
GzzData
DOCUMENT ME!private float
hiThres
DOCUMENT ME!private int[]
kExtents
DOCUMENT ME!private float
loThres
DOCUMENT ME!private float[]
outputBuffer
private float[]
sigmas
DOCUMENT ME!private ModelImage
zXMask
DOCUMENT ME!-
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 AlgorithmNMSuppression(ModelImage srcImg, float[] sigmas, boolean maskFlag, boolean img25D)
AlgorithmNMSuppression - Constructor.AlgorithmNMSuppression(ModelImage destImg, ModelImage srcImg, float[] sigmas, boolean maskFlag, boolean img25D)
AlgorithmNMSuppression - Constructor.
-
Method Summary
All Methods Static 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).private void
calcInPlace2D(int nImages)
Calculates the non-maximum suppression image and replaces the source image with the new image.private void
calcInPlace3D()
Calculates the non-maximum suppression and replaces the source image with the new image.private void
calcStoreInDest2D(int nImages)
This function produces the non-maximum suppression of input image.private void
calcStoreInDest3D()
This function produces the Non-maximum suppression of input image.void
finalize()
Prepares this class for destruction.static void
genLevelMask(int xDim, int yDim, float[] buffer, java.util.BitSet edgeImage, float level)
Generates a zero crossing mask for a 2D function sets a Bitset object to 1 is a zero crossing is detected.void
genZeroXMask(float[] buffer, float[] buffer2)
Generates a zero crossing mask for a 2D function sets a ModelImage to 1 if a zero crossing is detected.ModelImage
getZeroXMask()
Accessor to return mask indicating zero crossings.private void
makeKernels2D()
Creates 2D Gaussian derivative kernels.private void
makeKernels3D()
Creates 3D Gaussian derivative kernels.void
runAlgorithm()
Starts the program.void
setEdgeOptions(float loThres, float hiThres)
Call from dialog if you wish to produce edge image.-
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
-
edgeImage
private boolean edgeImage
DOCUMENT ME!
-
entireImage
private boolean entireImage
DOCUMENT ME!
-
GxData
private float[] GxData
DOCUMENT ME!
-
GxxData
private float[] GxxData
DOCUMENT ME!
-
GxxxData
private float[] GxxxData
DOCUMENT ME!
-
GxxyData
private float[] GxxyData
DOCUMENT ME!
-
GxyData
private float[] GxyData
DOCUMENT ME!
-
GxyyData
private float[] GxyyData
DOCUMENT ME!
-
GxzData
private float[] GxzData
DOCUMENT ME!
-
GyData
private float[] GyData
DOCUMENT ME!
-
GyyData
private float[] GyyData
DOCUMENT ME!
-
GyyyData
private float[] GyyyData
DOCUMENT ME!
-
GyzData
private float[] GyzData
DOCUMENT ME!
-
GzData
private float[] GzData
DOCUMENT ME!
-
GzzData
private float[] GzzData
DOCUMENT ME!
-
kExtents
private int[] kExtents
DOCUMENT ME!
-
loThres
private float loThres
DOCUMENT ME!
-
hiThres
private float hiThres
DOCUMENT ME!
-
sigmas
private float[] sigmas
DOCUMENT ME!
-
zXMask
private ModelImage zXMask
DOCUMENT ME!
-
outputBuffer
private float[] outputBuffer
-
-
Constructor Detail
-
AlgorithmNMSuppression
public AlgorithmNMSuppression(ModelImage srcImg, float[] sigmas, boolean maskFlag, boolean img25D)
AlgorithmNMSuppression - Constructor.- Parameters:
srcImg
- source image modelsigmas
- Gaussian's standard deviations in the each dimensionmaskFlag
- Flag that indicates that the non-maximum suppression will be calculated for the whole image if equal to trueimg25D
- Flag, if true, indicates that each slice of the 3D volume should be processed independently. 2D images disregard this flag.
-
AlgorithmNMSuppression
public AlgorithmNMSuppression(ModelImage destImg, ModelImage srcImg, float[] sigmas, boolean maskFlag, boolean img25D)
AlgorithmNMSuppression - Constructor.- Parameters:
destImg
- image model where result image is to storedsrcImg
- source image modelsigmas
- Gaussian's standard deviations in the each dimensionmaskFlag
- Flag that indicates that the non-maximum suppression will be calculated for the whole image if equal to trueimg25D
- Flag, if true, indicates that each slice of the 3D volume should be processed independently. 2D images disregard this flag.
-
-
Method Detail
-
genLevelMask
public static void genLevelMask(int xDim, int yDim, float[] buffer, java.util.BitSet edgeImage, float level)
Generates a zero crossing mask for a 2D function sets a Bitset object to 1 is a zero crossing is detected.- Parameters:
xDim
- X dimension lengthyDim
- Y dimension lengthbuffer
- array of data in which to find level crossingedgeImage
- edge map of level crossingslevel
- level of crossings to find (e.g. zero crossing of the non-maximum suppression)
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
genZeroXMask
public void genZeroXMask(float[] buffer, float[] buffer2)
Generates a zero crossing mask for a 2D function sets a ModelImage to 1 if a zero crossing is detected.- Parameters:
buffer
- array in which to find zero crossingbuffer2
- array which ensures that zero crossing is only counted if buffer2 value at that position is less than zero
-
getZeroXMask
public ModelImage getZeroXMask()
Accessor to return mask indicating zero crossings.- Returns:
- - ModelImage of zero crossings ( 2D function 1 = indicates zero crossing
-
runAlgorithm
public void runAlgorithm()
Starts the program.- Specified by:
runAlgorithm
in classAlgorithmBase
-
setEdgeOptions
public void setEdgeOptions(float loThres, float hiThres)
Call from dialog if you wish to produce edge image.- Parameters:
loThres
- DOCUMENT ME!hiThres
- DOCUMENT ME!
-
calcInPlace2D
private void calcInPlace2D(int nImages)
Calculates the non-maximum suppression image and replaces the source image with the new image.- Parameters:
nImages
- number of images to be blurred. 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.
-
calcInPlace3D
private void calcInPlace3D()
Calculates the non-maximum suppression and replaces the source image with the new image.
-
calcStoreInDest2D
private void calcStoreInDest2D(int nImages)
This function produces the non-maximum suppression of input image.- Parameters:
nImages
- number of images to be blurred. 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.
-
calcStoreInDest3D
private void calcStoreInDest3D()
This function produces the Non-maximum suppression of input image.
-
makeKernels2D
private void makeKernels2D()
Creates 2D Gaussian derivative kernels.
-
makeKernels3D
private void makeKernels3D()
Creates 3D 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
-
-