Class 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 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.
      • 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 stored
        srcImg - source image model
        sigmas - Gaussian's standard deviations in the each dimension
        maskFlag - Flag that indicates that the EdgeLap will be calculated for the whole image if equal to true
        img25D - 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 image
        yDim - y dimension of image
        buffer - array in which to find zero crossing
        level - level to generate zero crossings at
        detectionType - 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 in
        extents - 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 class AlgorithmBase
      • 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 crossing
        detectionType - 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
      • 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 interface AlgorithmInterface
        Parameters:
        algorithm - the algorithm which has just completed