]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/SkeletonFilter.h
...
[FrontAlgorithms.git] / lib / fpa / Image / SkeletonFilter.h
index 595170928391420ae7824312f9ce8054d117265b..6ed2b3289daa20469ea8fb63994ae2e4fa3f231b 100644 (file)
@@ -1,10 +1,16 @@
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+
 #ifndef __fpa__Image__SkeletonFilter__h__
 #define __fpa__Image__SkeletonFilter__h__
 
-#include <itkProcessObject.h>
-#include <fpa/Image/MinimumSpanningTree.h>
-#include <cpExtensions/DataStructures/Skeleton.h>
-#include <set>
+#include <fpa/Image/Dijkstra.h>
+
+#include <map>
+#include <itkSignedMaurerDistanceMapImageFilter.h>
+#include <fpa/Base/Skeleton.h>
 
 namespace fpa
 {
@@ -12,92 +18,70 @@ namespace fpa
   {
     /**
      */
-    template< class _TDistanceMap, class _TCostMap >
+    template< class _TImage, class _TScalar = double >
     class SkeletonFilter
-      : public itk::ProcessObject
+      : public fpa::Image::Dijkstra< itk::Image< _TScalar, _TImage::ImageDimension >, itk::Image< _TScalar, _TImage::ImageDimension > >
     {
     public:
-      typedef SkeletonFilter                  Self;
-      typedef itk::ProcessObject              Superclass;
-      typedef itk::SmartPointer< Self >       Pointer;
+      // Smart pointers
+      typedef _TImage  TImage;
+      typedef _TScalar TScalar;
+      typedef itk::Image< TScalar, TImage::ImageDimension > TScalarImage;
+      typedef SkeletonFilter Self;
+      typedef fpa::Image::Dijkstra< TScalarImage, TScalarImage > Superclass;
+      typedef itk::SmartPointer< Self > Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-#ifdef ITK_USE_CONCEPT_CHECKING
-      itkConceptMacro(
-        SameDimension,
-        ( itk::Concept::SameDimension< _TDistanceMap::ImageDimension, _TCostMap::ImageDimension > )
-        );
-#endif
-      typedef _TDistanceMap TDistanceMap;
-      typedef _TCostMap     TCostMap;
-      typedef typename TCostMap::IndexType TIndex;
-      typedef MinimumSpanningTree< TCostMap::ImageDimension > TMST;
-      typedef
-      cpExtensions::DataStructures::Skeleton< TCostMap::ImageDimension >
-      TSkeleton;
-      typedef itk::Image< unsigned char, _TCostMap::ImageDimension > TMarks;
-
-      typedef
-      itk::Functor::IndexLexicographicCompare< _TCostMap::ImageDimension >
-      TIndexCompare;
-      typedef std::set< TIndex, TIndexCompare > TIndicesData;
-      typedef itk::SimpleDataObjectDecorator< TIndicesData > TIndices;
+      typedef typename Superclass::TMST         TMST;
+      typedef typename Superclass::TVertex      TVertex;
+      typedef typename Superclass::TOutputValue TOutputValue;
 
-    public:
-      itkNewMacro( Self );
-      itkTypeMacro( fpa::Image::SkeletonFilter, itk::Object );
+      typedef itk::SignedMaurerDistanceMapImageFilter< TImage, TScalarImage > TDistanceMap;
+      typedef itk::Image< unsigned char, TImage::ImageDimension > TMarks;
+      typedef fpa::Base::Skeleton< TImage::ImageDimension > TSkeleton;
 
+    protected:
+      typedef std::multimap< TScalar, TVertex, std::greater< TScalar > > _TSkeletonQueue;
+      typedef std::map< TVertex, TVertex, typename TVertex::LexicographicCompare > _TAdjacencies;
+      
     public:
-      _TDistanceMap* GetDistanceMap( );
-      const _TDistanceMap* GetDistanceMap( ) const;
-      void SetDistanceMap( _TDistanceMap* dmap );
-
-      _TCostMap* GetCostMap( );
-      const _TCostMap* GetCostMap( ) const;
-      void SetCostMap( _TCostMap* cmap );
-
-      TMST* GetMinimumSpanningTree( );
-      const TMST* GetMinimumSpanningTree( ) const;
-      void SetMinimumSpanningTree( TMST* mst );
+      itkNewMacro( Self );
+      itkTypeMacro( fpa::Image::SkeletonFilter, fpa::Image::Dijkstra );
 
-      TIndices* GetEndPoints( );
-      const TIndices* GetEndPoints( ) const;
+      itkBooleanMacro( SeedFromMaximumDistance );
+      itkGetConstMacro( SeedFromMaximumDistance, bool );
+      itkSetMacro( SeedFromMaximumDistance, bool );
 
-      TIndices* GetBifurcations( );
-      const TIndices* GetBifurcations( ) const;
+    public:
+      virtual void SetInput( const TScalarImage* image ) override;
+      void SetInput( const TImage* image );
+      TImage* GetInput( );
+      const TImage* GetInput( ) const;
 
       TSkeleton* GetSkeleton( );
-      const TSkeleton* GetSkeleton( ) const;
-
       TMarks* GetMarks( );
-      const TMarks* GetMarks( ) const;
 
     protected:
       SkeletonFilter( );
       virtual ~SkeletonFilter( );
 
-      virtual void GenerateData( ) fpa_OVERRIDE;
+      virtual void GenerateData( ) override;
+      virtual void _SetOutputValue( const TVertex& vertex, const TOutputValue& value ) override;
 
-      void _EndPoints(
-        const TDistanceMap* dmap,
-        const TCostMap* cmap,
-        const TMST* mst,
-        TIndicesData& end_points
-        );
-
-      void _Skeleton(
-        const TDistanceMap* dmap,
-        const TCostMap* cmap,
-        const TMST* mst,
-        const TIndicesData& end_points,
-        TIndicesData& bifurcations,
-        TSkeleton* skeleton
-        );
+      void _EndPoints( std::vector< TVertex >& end_points, _TAdjacencies& A );
+      void _Skeleton( const std::vector< TVertex >& end_points, _TAdjacencies& A );
+      void _MarkSphere( const TVertex& idx );
 
     private:
-      // Purposely not defined
       SkeletonFilter( const Self& other );
       Self& operator=( const Self& other );
+
+    protected:
+      bool m_SeedFromMaximumDistance;
+      typename TDistanceMap::Pointer m_DistanceMap;
+      _TSkeletonQueue m_SkeletonQueue;
+      unsigned long m_SkeletonIdx;
+      unsigned long m_MarksIdx;
     };
 
   } // ecapseman