Package gov.nih.mipav.model.algorithms
Class AlgorithmEdgeLaplacianSep
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.AlgorithmEdgeLaplacianSep
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmEdgeLaplacianSep extends AlgorithmBase
Calculates the EdgeLap of an image at a scale defined by the user. This algorithm produces an edge map of the zero crossings of the laplacian of the gaussian for 2D images and 2.5D images. This version uses the separable kernel convolution algorithm (faster, but uses more memory). If clearInflectionPoints is true, remove zero crossings which do not correspond to actual edges but to inflection points instead. If a zero crossing is not a point of inflection, then in the direction perpendicular to the crossing edge the sign of the simple central difference operator of the Gaussian of the image times the sign of the third-degree central difference operator of the Gaussian of the image must be less than zero. Reference: "Refining Edges Detected by a LoG Operator" by Fatih Ulupinar and Gerard Medioni, Computer Vision, Graphics, and Image Processing, Vol. 51, 1990, pp. 275-298.Note: From Design of FIR bilevel Laplacian-of-Gaussian filter by Soo-Chang Pei and Ji-Hwei Horng: "Wiejak showed that the LoG filter may be decomposed into the sum of two separable filters: LoG(X,Y) = -G"(x)*G(y) - G(x)*G"(y) where G and G" are the 1D Gaussian and the second derivative of the 1D Gaussian." The reference is J.S. Wiejak, H. Buxton, and B. F. Buxton, "Convolution with separable masks for early image processing", Computer Vision, Graphics, and Image Processing, 32, 1985, pp. 279-290. Results almost exactly match those of AlgorithmEdgeLaplacian.
Does not work with color images (neither does AlgorithmEdgeLaplacian).
- Version:
- 0.1 Aug 4, 2003
- Author:
- Evan McCreedy
- See Also:
AlgorithmEdgeLaplacian
-
-
Field Summary
Fields Modifier and Type Field Description private int
clearedPoints
private boolean
clearInflectionPoints
private boolean
entireImage
Flag, if true, indicates that the whole image should be processed.private float[]
gaussBuffer
private float[]
GxxData
Storage location of the second derivative of the Gaussian in the X direction.private float[]
GyyData
Storage location of the second derivative of the Gaussian in the Y direction.private float[]
GzzData
Storage location of the second derivative of the Gaussian in the Z direction.private int[]
kExtents
Dimensionality of the kernel.static int
MARCHING_SQUARES
Perform zero crossing detection using the marching squares method.static int
NEGATIVE_EDGES
Mark negative areas of the laplacian image as edges (makes thicker edges - used in BSE).static int
OLD_DETECTION
Perform zero crossing detection using Matt's old method.private float[]
sigmas
Standard deviations of the gaussian used to calculate the kernels.private int
zeroDetectionType
The type of zero crossing detection to use.private ModelImage
zXMask
Mask(unsigned byte) of the zero-crossings of the Laplacian of the gaussian.-
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 AlgorithmEdgeLaplacianSep(ModelImage destImg, ModelImage srcImg, float[] sigmas, boolean maskFlag, boolean img25D, boolean clearInflectionPoints)
Creates a new AlgorithmEdgeLaplacianSep object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
calcStoreInDest2D(int nImages, int detectionType)
This function produces the EdgeLap of input image.private void
calcStoreInDest3D(int detectionType)
This function produces the EdgeLap of input image.java.util.BitSet
calcZeroXMaskBitset(float[] buffer, int[] extents)
Calculates the zero crossing mask of a 2D image and returns it as a BitSet buffer.void
finalize()
Prepares this class for destruction.static java.util.BitSet
genLevelMask(int xDim, int yDim, float[] buffer, float level, int detectionType)
Generates a zero crossing mask for a 2D function sets a Bitset object to 1 where a zero crossing is detected.void
genZeroXMask(int slice, float[] buffer, int detectionType)
Generates a zero crossing mask for a 2D function.ModelImage
getZeroXMask()
Accessor to return mask indicating zero crossings.private void
makeKernels2D()
Creates Gaussian derivative kernels.private void
makeKernels3D()
Creates Gaussian derivative kernels.void
runAlgorithm()
Starts the program.void
setZeroDetectionType(int type)
Changes the type of zero crossing detection method used.-
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
-
MARCHING_SQUARES
public static final int MARCHING_SQUARES
Perform zero crossing detection using the marching squares method.- See Also:
- Constant Field Values
-
OLD_DETECTION
public static final int OLD_DETECTION
Perform zero crossing detection using Matt's old method.- See Also:
- Constant Field Values
-
NEGATIVE_EDGES
public static final int NEGATIVE_EDGES
Mark negative areas of the laplacian image as edges (makes thicker edges - used in BSE).- See Also:
- Constant Field Values
-
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.
-
GxxData
private float[] GxxData
Storage location of the second derivative of the Gaussian in the X direction.
-
GyyData
private float[] GyyData
Storage location of the second derivative of the Gaussian in the Y direction.
-
GzzData
private float[] GzzData
Storage location of the second derivative of the Gaussian in the Z direction.
-
kExtents
private int[] kExtents
Dimensionality of the kernel.
-
sigmas
private float[] sigmas
Standard deviations of the gaussian used to calculate the kernels.
-
zeroDetectionType
private int zeroDetectionType
The type of zero crossing detection to use.
-
zXMask
private ModelImage zXMask
Mask(unsigned byte) of the zero-crossings of the Laplacian of the gaussian. Non-zero value indicates edge. Zero in the mask image is background.
-
clearInflectionPoints
private boolean clearInflectionPoints
-
clearedPoints
private int clearedPoints
-
gaussBuffer
private float[] gaussBuffer
-
-
Constructor Detail
-
AlgorithmEdgeLaplacianSep
public AlgorithmEdgeLaplacianSep(ModelImage destImg, ModelImage srcImg, float[] sigmas, boolean maskFlag, boolean img25D, boolean clearInflectionPoints)
Creates a new AlgorithmEdgeLaplacianSep object.- 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 EdgeLap 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.clearInflectionPoints
- If true, do not set zero crossings corresponding to points of inflection
-
-
Method Detail
-
genLevelMask
public static java.util.BitSet genLevelMask(int xDim, int yDim, float[] buffer, float level, int detectionType)
Generates a zero crossing mask for a 2D function sets a Bitset object to 1 where a zero crossing is detected.- Parameters:
xDim
- x dimension of imageyDim
- y dimension of imagebuffer
- array in which to find zero crossinglevel
- level to generate zero crossings atdetectionType
- the type of zero crossing method to use- Returns:
- Bitset representing zero crossings
-
calcZeroXMaskBitset
public java.util.BitSet calcZeroXMaskBitset(float[] buffer, int[] extents)
Calculates the zero crossing mask of a 2D image and returns it as a BitSet buffer.- Parameters:
buffer
- the slice to work withextents
- the extents of the image- Returns:
- BitSet buffer with mask set when a zero crossing is detected
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
genZeroXMask
public void genZeroXMask(int slice, float[] buffer, int detectionType)
Generates a zero crossing mask for a 2D function. Sets a ModelImage to 255 if a zero crossing is detected.- Parameters:
slice
- the slice of the volume which we are working on (0 if from 2D image)buffer
- array in which to find zero crossingdetectionType
- the type of zero crossing detection to perform
-
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
-
setZeroDetectionType
public void setZeroDetectionType(int type)
Changes the type of zero crossing detection method used.- Parameters:
type
- the zero crossing method to use
-
calcStoreInDest2D
private void calcStoreInDest2D(int nImages, int detectionType)
This function produces the EdgeLap of input image.- Parameters:
nImages
- number of images on which to find zero crossings. 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.detectionType
- the type of zero crossing detection to perform
-
calcStoreInDest3D
private void calcStoreInDest3D(int detectionType)
This function produces the EdgeLap of input image.- Parameters:
detectionType
- the type of zero crossing detection to perform
-
makeKernels2D
private void makeKernels2D()
Creates Gaussian derivative kernels.
-
makeKernels3D
private void makeKernels3D()
Creates Gaussian derivative kernels.
-
-