Class 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 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 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 where 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 slice to work with
        extents - 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 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 1 = 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 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.