Class LseSegThreshold2


  • public class LseSegThreshold2
    extends LseSegmenter
    A segmenter for 2D images based on the PDE described in LseThreshold2.
    Version:
    0.1 November 7, 2006
    Author:
    David Eberly
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private float[] m_afBlurCurvFlow
      The blurred curvature flow image (intermediate image).
      private float[] m_afCurvFlow
      The curvature flow image (intermediate image).
      private float[] m_afFeature
      The feature image.
      private float[] m_afGradMagBlurCurvFlow
      The gradient magnitude of the blurred curvature flow image (intermediate image).
      private int m_eScaleType
      The scaling type of the image (default = LsePdeFilter.NONE).
      private float m_fAlpha
      The default parameters used in the sigmoid function that modifies the gradient magnitude (default alpha = 1, default beta = 0, default min = 0, default max = 1).
      private float m_fBeta
      The default parameters used in the sigmoid function that modifies the gradient magnitude (default alpha = 1, default beta = 0, default min = 0, default max = 1).
      private float m_fBorderValue
      The border value of the image (default = Float.MAX_VALUE).
      private float m_fLower
      Parameters for the threshold segmentation.
      private float m_fMax
      The default parameters used in the sigmoid function that modifies the gradient magnitude (default alpha = 1, default beta = 0, default min = 0, default max = 1).
      private float m_fMin
      The default parameters used in the sigmoid function that modifies the gradient magnitude (default alpha = 1, default beta = 0, default min = 0, default max = 1).
      private float m_fScale
      The scale used for computing the blurred gradient magnitude image (default = 0).
      private float m_fTimeStep
      The time step of the PDE solver (default = 0.001).
      private float m_fUpper
      Parameters for the threshold segmentation.
      private float m_fXSpacing
      The x-spacing of the image.
      private float m_fYSpacing
      The y-spacing of the image.
      private int m_iDIterations
      The number of iterations to use in the nonlinear diffusion used to create the feature image (default = 0).
      private int m_iXBound
      The x-bound of the image.
      private int m_iYBound
      The y-bound of the image.
    • Constructor Summary

      Constructors 
      Constructor Description
      LseSegThreshold2​(int iXBound, int iYBound, float fXSpacing, float fYSpacing, float[] afData, boolean[] abMask)
      Create a threshold-based segmenter.
    • Field Detail

      • m_iXBound

        private int m_iXBound
        The x-bound of the image.
      • m_iYBound

        private int m_iYBound
        The y-bound of the image.
      • m_fXSpacing

        private float m_fXSpacing
        The x-spacing of the image.
      • m_fYSpacing

        private float m_fYSpacing
        The y-spacing of the image.
      • m_fBorderValue

        private float m_fBorderValue
        The border value of the image (default = Float.MAX_VALUE).
      • m_eScaleType

        private int m_eScaleType
        The scaling type of the image (default = LsePdeFilter.NONE).
      • m_fTimeStep

        private float m_fTimeStep
        The time step of the PDE solver (default = 0.001).
      • m_iDIterations

        private int m_iDIterations
        The number of iterations to use in the nonlinear diffusion used to create the feature image (default = 0).
      • m_fScale

        private float m_fScale
        The scale used for computing the blurred gradient magnitude image (default = 0).
      • m_fAlpha

        private float m_fAlpha
        The default parameters used in the sigmoid function that modifies the gradient magnitude (default alpha = 1, default beta = 0, default min = 0, default max = 1).
      • m_fBeta

        private float m_fBeta
        The default parameters used in the sigmoid function that modifies the gradient magnitude (default alpha = 1, default beta = 0, default min = 0, default max = 1).
      • m_fMin

        private float m_fMin
        The default parameters used in the sigmoid function that modifies the gradient magnitude (default alpha = 1, default beta = 0, default min = 0, default max = 1).
      • m_fMax

        private float m_fMax
        The default parameters used in the sigmoid function that modifies the gradient magnitude (default alpha = 1, default beta = 0, default min = 0, default max = 1).
      • m_afFeature

        private float[] m_afFeature
        The feature image.
      • m_afCurvFlow

        private float[] m_afCurvFlow
        The curvature flow image (intermediate image).
      • m_afBlurCurvFlow

        private float[] m_afBlurCurvFlow
        The blurred curvature flow image (intermediate image).
      • m_afGradMagBlurCurvFlow

        private float[] m_afGradMagBlurCurvFlow
        The gradient magnitude of the blurred curvature flow image (intermediate image).
      • m_fLower

        private float m_fLower
        Parameters for the threshold segmentation.
      • m_fUpper

        private float m_fUpper
        Parameters for the threshold segmentation.
    • Constructor Detail

      • LseSegThreshold2

        public LseSegThreshold2​(int iXBound,
                                int iYBound,
                                float fXSpacing,
                                float fYSpacing,
                                float[] afData,
                                boolean[] abMask)
        Create a threshold-based segmenter.
        Parameters:
        iXBound - The x-bound of the image.
        iYBound - The y-bound of the image.
        fXSpacing - The x-spacing of the image.
        fYSpacing - The y-spacing of the image.
        afData - The image elements.
        abMask - The image masks that determine which pixels are processed by the segmenter.
    • Method Detail

      • setPDEParameters

        public final void setPDEParameters​(float fBorderValue,
                                           int eScaleType,
                                           float fTimeStep)
        Parameters for the feature image creation. You may set these anytime before a sequence of fast-march iterations. The PDE filters require you to specify how to handle boundary values. If you want Dirichlet conditions (constant boundary), set BorderValue to a finite number. If you want Neumann conditions (zero-derivative boundary), set the BorderValue to Float.MAX_VALUE. If you want the original image to be scaled, choose the Type parameter appropriately. The input image is processed by a curvature-based anisotropic diffusion filter; the number of iterations is DIterations. The gradient magnitude at the specified Scale is computed for the output of the diffusion filter. The gradient magnitude is transformed to the feature image by a sigmoid function:

           feature(x) = min + (max-min)/(1 + exp(-(x-beta)/alpha))

        The inverse of the feature image values are the speeds used in the fast marching algorithm.
        Specified by:
        setPDEParameters in class LseSegmenter
        Parameters:
        fBorderValue - The border value to use when processing boundary pixels.
        eScaleType - The scaling type for the image.
        fTimeStep - The time step for the PDE solver.
      • setDiffusionIterations

        public final void setDiffusionIterations​(int iDIterations)
        Set the number of iterations to use in the nonlinear diffusion (curvature flow filter) applied to the input image.
        Specified by:
        setDiffusionIterations in class LseSegmenter
        Parameters:
        iDIterations - The number of iterations.
      • setGradientMagnitudeScale

        public final void setGradientMagnitudeScale​(float fScale)
        Set the scale to use in computing the blurred gradient magnitude of the curvature flow image.
        Specified by:
        setGradientMagnitudeScale in class LseSegmenter
        Parameters:
        fScale - The scale for the blurred gradient magnitude image.
      • setSigmoidFilter

        public final void setSigmoidFilter​(float fAlpha,
                                           float fBeta,
                                           float fMin,
                                           float fMax)
        Set the parameters for the sigmoid function through which the blurred gradient magnitude image is processed.
        Specified by:
        setSigmoidFilter in class LseSegmenter
        Parameters:
        fAlpha - The variance of the function.
        fBeta - The center of the function.
        fMin - The minimum of the function.
        fMax - The maximum of the function.
      • createFeatureImage

        public final void createFeatureImage()
        Create the feature image using the parameters set by the four parameter-setting functions defined above. Since the quality of the segmentation depends on these parameters, createFeatureImage() allows you to experiment with the parameters before you start the segmentation.
      • getFeatureImage

        float[] getFeatureImage()
        Get the feature image. The result is relevant only after a call to computeFeatureImage or beginCoarse.
        Returns:
        The feature image.
      • getCurvFlowImage

        float[] getCurvFlowImage()
        Get the curvature flow image. The result is relevant only after a call to computeFeatureImage or beginCoarse.
        Returns:
        The curvature flow image.
      • getBlurCurvFlowImage

        float[] getBlurCurvFlowImage()
        Get the blurred curvature flow image. The result is relevant only after a call to computeFeatureImage or beginCoarse.
        Returns:
        The blurred curvature flow image.
      • getGradMagBlurCurvFlowImage

        float[] getGradMagBlurCurvFlowImage()
        Get the gradient magnitude of the blurred curvature flow image. The result is relevant only after a call to computeFeatureImage or beginCoarse.
        Returns:
        The gradient magnitude of the blurred curvature flow image.
      • beginCoarse

        public void beginCoarse​(int[] aiSeeds)
        The region-growing fast march. When you call beginCoarse(), the current parameters are used (DIterations, scale, alpha, beta, min, max). You can apply the fast marching algorithm multiple times to the same image, each time starting with beginCoarse();
        Overrides:
        beginCoarse in class LseSegmenter
        Parameters:
        aiSeeds - The initial region to grow.
      • beginDistanceTransform

        public boolean beginDistanceTransform​(float fMaxDistance)
        The signed-distance-transform fast march. An annulus is computed about the boundary of the coarse-level segmentation. The maximum distance from annulus points to the boundary is the input to this function (in pixel units).
        Overrides:
        beginDistanceTransform in class LseSegmenter
        Parameters:
        fMaxDistance - The maximum distance to allow when computing the signed distance transform.
        Returns:
        'true' iff more iterations are allowed
      • setThresholds

        public void setThresholds​(float fLower,
                                  float fUpper)
        The lower and upper thresholds must be set before calling beginEvolution.
        Parameters:
        fLower - The lower threshold for propagation P(x) in the PDE.
        fUpper - The upper threshold for propagation P(x) in the PDE.
      • beginEvolution

        public void beginEvolution​(float fAdvectionWeight,
                                   float fPropagationWeight,
                                   float fCurvatureWeight,
                                   float fLaplacianWeight,
                                   float fTimeStep)
        The level-set evolution.
        Overrides:
        beginEvolution in class LseSegmenter
        Parameters:
        fAdvectionWeight - The advection coefficient 'a' in the PDE that controls the evolution.
        fPropagationWeight - The propagation coefficient 'b' in the PDE that controls the evolution.
        fCurvatureWeight - The curvature coefficient 'c' in the PDE that controls the evolution.
        fLaplacianWeight - The Laplacian coefficient 'd' in the PDE that controls the evolution.
        fTimeStep - The time step for the PDE solver.