Package gov.nih.mipav.model.algorithms
Class AlgorithmEdgeLaplacian
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.AlgorithmEdgeLaplacian
-
- All Implemented Interfaces:
AlgorithmInterface
,java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmEdgeLaplacian extends AlgorithmBase implements AlgorithmInterface
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. 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.- Version:
- 0.1 Feb 11, 1998
- Author:
- Matthew J. McAuliffe, Ph.D.
-
-
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 int
operationType
private float[]
outputBufferX
private float[]
outputBufferY
private float[]
outputBufferZ
private float[]
sigmas
Standard deviations of the gaussian used to calculate the kernels.private static int
xOp
private static int
yOp
private int
zeroDetectionType
The type of zero crossing detection to use.private static int
zOp
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 AlgorithmEdgeLaplacian(ModelImage destImg, ModelImage srcImg, float[] sigmas, boolean maskFlag, boolean img25D, boolean clearInflectionPoints)
Creates a new AlgorithmEdgeLaplacian object.
-
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
calcStoreInDest2D(int nImages, int detectionType)
This function produces the EdgeLap of input image.private void
calcStoreInDest3D(int detectionType)
This function produces the Laplacian 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 is 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
-
xOp
private static final int xOp
- See Also:
- Constant Field Values
-
yOp
private static final int yOp
- See Also:
- Constant Field Values
-
zOp
private static final int zOp
- 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.
-
outputBufferX
private float[] outputBufferX
-
outputBufferY
private float[] outputBufferY
-
outputBufferZ
private float[] outputBufferZ
-
operationType
private int operationType
-
clearInflectionPoints
private boolean clearInflectionPoints
-
clearedPoints
private int clearedPoints
-
gaussBuffer
private float[] gaussBuffer
-
-
Constructor Detail
-
AlgorithmEdgeLaplacian
public AlgorithmEdgeLaplacian(ModelImage destImg, ModelImage srcImg, float[] sigmas, boolean maskFlag, boolean img25D, boolean clearInflectionPoints)
Creates a new AlgorithmEdgeLaplacian 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 is 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 buffer to find the edges inextents
- the extents of the image the buffer came from- 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); 255 = 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 Laplacian 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.
-
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
-
-