Class Skeleton3D


  • public class Skeleton3D
    extends java.lang.Object
    Implementation of the 3D skeletonization of a binary volume based on the paper "Penalized-distance volumetric skeleton algorithm"; I. Bitter, A. Kaufman, M. Sato; IEEE Transactions on Visualization and Computer Graphics, Vol. 7, No. 3, pp. 195-206, July-September 2001.
    • Constructor Summary

      Constructors 
      Constructor Description
      Skeleton3D​(ModelImage kImage, ModelImage3DLayout kVolumeLayout)
      Create a 3D skeletonization of the specified binary volume of data.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void computeVolumeBoundaryDist​(WildMagic.LibFoundation.Mathematics.Vector3f[] akVolumeBoundaryDistGradient)
      Compute the Euclidean distance from each sample "inside" the volume to the nearest point on the surface surrounding the volume.
      void dispose()
      Called to free up resources.
      void finalize()
      Called by the garbage collector.
      float getMaxBoundaryDistance()
      Access the maximum distance of any "inside" point to the boundary.
      FlyPathGraphSamples getPathGraph​(int iMaxBranches, float fMinBranchLength)
      Given previously determined starting point, compute the tree-structured skeleton path through the volume where no branch is shorter than the specified amount.
      short[] getSkeletonizedArray​(int iMaxBranches, float fMinBranchLength)
      Given previously determined starting point, compute the tree-structured skeleton path through the volume where no branch is shorter than the specified amount.
      private void markPossibleSkeletonSamples​(WildMagic.LibFoundation.Mathematics.Vector3f[] akVolumeBoundaryDistGradient)
      Mark all inside samples that have nonuniform boundary distance gradients and then "connect" such samples by following the gradient.
      private void markSkeletonPoint​(int iIndex, float fNeighborRadius)
      Mark the specified volume sample as being part of the skeleton and mark all the connected samples within the specified radius of the specified sample as being neighbors.
      private void saveVolume​(java.lang.String kFilename, int iFileType, short[] asVolumeData)
      Write the specified volume to the file of the specified name.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEBUG

        private static final boolean DEBUG
        Set this flag to allow the output of volume file which result as part of the computation.
        See Also:
        Constant Field Values
      • RESULT_MASK_INSIDE

        private static final short RESULT_MASK_INSIDE
        These are bit masks used in the result volume which identifies how samples were classified at different steps during the processing. RESULT_MASK_INSIDE - subset of all samples; those that are inside RESULT_MASK_NONUNIFORM_GRADIENT - subset of samples marked with RESULT_MASK_INSIDE that have nonuniform boundary distance gradients RESULT_MASK_FLAGGED - subset of samples marked with RESULT_MASK_INSIDE and including all samples marked with RESULT_MASK_NONUNIFORM_GRADIENT are those samples that connected those samples marked with RESULT_MASK_NONUNIFORM_GRADIENT RESULT_MASK_CONNECTED - subset of samples marked with RESULT_MASK_FLAGGED that are largest 26-connected collection of samples marked with RESULT_MASK_FLAGGED RESULT_MASK_SKELETON - subset of samples marked with RESULT_MASK_CONNECTED that are the samples which make up the the skeleton of the binary volume RESULT_MASK_SKELETON_NEIGHBOR - the subset of samples marked RESULT_MARK_CONNECTED that within a certain radius of samples marked as RESULT_MARK_SKELETON.
        See Also:
        Constant Field Values
      • RESULT_MASK_NONUNIFORM_GRADIENT

        private static final short RESULT_MASK_NONUNIFORM_GRADIENT
        DOCUMENT ME!
        See Also:
        Constant Field Values
      • RESULT_MASK_FLAGGED

        private static final short RESULT_MASK_FLAGGED
        DOCUMENT ME!
        See Also:
        Constant Field Values
      • RESULT_MASK_CONNECTED

        private static final short RESULT_MASK_CONNECTED
        DOCUMENT ME!
        See Also:
        Constant Field Values
      • RESULT_MASK_SKELETON_NEIGHBOR

        private static final short RESULT_MASK_SKELETON_NEIGHBOR
        DOCUMENT ME!
        See Also:
        Constant Field Values
      • RESULT_MASK_SKELETON

        private static final short RESULT_MASK_SKELETON
        DOCUMENT ME!
        See Also:
        Constant Field Values
      • m_afBoundarySampleDistMin

        private float[] m_afBoundarySampleDistMin
        Array of Euclidean distances to the nearest boundary for each inside voluem sample. Distances are in sample coordinates. Also compute the maximum of these values.
      • m_asVolumeData

        private short[] m_asVolumeData
        Volume of bitmasked values associated with each sample. The bitmask values are used to classify each sample during the various stages of the skeletonization process.
      • m_fMaxBoundarySampleDistMin

        private float m_fMaxBoundarySampleDistMin
        DOCUMENT ME!
      • m_iIndexPathStart

        private int m_iIndexPathStart
        This the linear array index for the sample from which all computed paths will originate.
      • m_kImage

        private ModelImage m_kImage
        Contains the image being skeletonized.
      • m_kVolumeLayout

        private ModelImage3DLayout m_kVolumeLayout
        Describes the organization of the volume data in a linear array.
    • Constructor Detail

      • Skeleton3D

        public Skeleton3D​(ModelImage kImage,
                          ModelImage3DLayout kVolumeLayout)
        Create a 3D skeletonization of the specified binary volume of data.
        Parameters:
        kImage - ModelImage contains the volume layout and its data
        kVolumeLayout - ModelImage3DLayout Contains the mapping between sample coordiantes and real coordinates for the input volume.
        Throws:
        java.lang.IllegalArgumentException - DOCUMENT ME!
    • Method Detail

      • dispose

        public void dispose()
        Called to free up resources.
      • finalize

        public void finalize()
        Called by the garbage collector.
        Overrides:
        finalize in class java.lang.Object
      • getMaxBoundaryDistance

        public float getMaxBoundaryDistance()
        Access the maximum distance of any "inside" point to the boundary.
        Returns:
        float Maximum of distances.
      • getPathGraph

        public FlyPathGraphSamples getPathGraph​(int iMaxBranches,
                                                float fMinBranchLength)
        Given previously determined starting point, compute the tree-structured skeleton path through the volume where no branch is shorter than the specified amount.
        Parameters:
        iMaxBranches - int Maximum number of branches to extract.
        fMinBranchLength - float All branches must be longer than this length.
        Returns:
        FlyPathGraphSamples A tree-structured skeleton path where each path is represented by its samples.
      • getSkeletonizedArray

        public short[] getSkeletonizedArray​(int iMaxBranches,
                                            float fMinBranchLength)
        Given previously determined starting point, compute the tree-structured skeleton path through the volume where no branch is shorter than the specified amount.
        Parameters:
        iMaxBranches - int Maximum number of branches to extract.
        fMinBranchLength - float All branches must be longer than this length.
        Returns:
        FlyPathGraphSamples A tree-structured skeleton path where each path is represented by its samples.
      • computeVolumeBoundaryDist

        private void computeVolumeBoundaryDist​(WildMagic.LibFoundation.Mathematics.Vector3f[] akVolumeBoundaryDistGradient)
        Compute the Euclidean distance from each sample "inside" the volume to the nearest point on the surface surrounding the volume. Based on the algorithm described in "New algorithms for Euclidean distance transformation of an n-dimensional digitized picture with applications", by T. Saito and J. Toriwaki, Pattern Recognition, Vol. 27, No. 11, pp. 1551-1565, 1994. Fills in the m_afBoundarySampleDistMin linear array of floating point values with the Euclidean distance measures; zero values will be stored in the array corresponding to samples outside the surface. Compute the penalty value associated with each sample based on its relative distance to the boundary. Compute the gradient of the distance field at each sample inside the surface (indicated by a positive distance measure).
        Parameters:
        akVolumeBoundaryDistGradient - Vector3f[] Array of normalized boundary distance gradients computed at each sample. The input array is assumed to have all entries null. Upon return, only those samples that are inside the volume will have a gradient value stored.
      • markPossibleSkeletonSamples

        private void markPossibleSkeletonSamples​(WildMagic.LibFoundation.Mathematics.Vector3f[] akVolumeBoundaryDistGradient)
        Mark all inside samples that have nonuniform boundary distance gradients and then "connect" such samples by following the gradient. Updates the m_asVolumeData linear array of 16-bit signed bit mask values representing the state of each sample in the skeletonziation algorithm. The RESULT_MASK_* constant bit masks are OR'ed into this field. Any sample having nonuniform gradients will be marked with the RESULT_MASK_NONUNIFORM_GRADIENT bit mask and the RESULT_MASK_FLAGGED bit mask. Any sample along the gradient path of connecting the nonuniform gradient samples will be marked only with the RESULT_MASK_FLAGGED bit mask. This array has values already set upon input and only OR's in additional bit masks.
        Parameters:
        akVolumeBoundaryDistGradient - linear array of Vector3f instances representing the (unnormalized) boundary distance gradient vectors for inside samples. The null reference will be stored for outside samples.
      • markSkeletonPoint

        private void markSkeletonPoint​(int iIndex,
                                       float fNeighborRadius)
        Mark the specified volume sample as being part of the skeleton and mark all the connected samples within the specified radius of the specified sample as being neighbors.
        Parameters:
        iIndex - int Identifies the sample in the volume to be markes as being on the skeleton path.
        fNeighborRadius - float Radius of connected neighbors to mark as being skeleton neighbors.
      • saveVolume

        private void saveVolume​(java.lang.String kFilename,
                                int iFileType,
                                short[] asVolumeData)
        Write the specified volume to the file of the specified name.
        Parameters:
        kFilename - name of the file for storing the volume
        iFileType - type of file selected from one of the constants defined in FileBase class.
        asVolumeData - linear array of signed 16-bit values containing the volume data at each sample where the samples are identified by the specified volume layout