]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Tue, 18 Jul 2017 21:45:09 +0000 (16:45 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Tue, 18 Jul 2017 21:45:09 +0000 (16:45 -0500)
lib/fpa/Base/Algorithm.h
lib/fpa/Base/Algorithm.hxx
lib/fpa/Image/Algorithm.h
lib/fpa/Image/Algorithm.hxx
lib/fpa/Image/DefaultTraits.h [new file with mode: 0644]
lib/fpa/Image/Dijkstra.h
lib/fpa/Image/Mori.h
lib/fpa/Image/RandomWalker.h
lib/fpa/Image/RegionGrow.h

index 5a02d6ebc2e0843a0e6d0bdb1132983c3c22a173..785b818ea8be76bdf3290896cf8c95f63b41bf55 100644 (file)
@@ -8,7 +8,6 @@
 
 #include <fpa/Config.h>
 
-#include <vector>
 #include <itkObject.h>
 #include <itkEventObject.h>
 
@@ -18,28 +17,28 @@ namespace fpa
   {
     /**
      */
-    template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
+    template< class _TTraits >
     class Algorithm
-      : public _TFilter,
-        public _TMarksInterface,
-        public _TSeedsInterface
+      : public _TTraits::TFilter,
+        public _TTraits::TMarksInterface,
+        public _TTraits::TSeedsInterface
     {
     public:
-      typedef Algorithm                       Self;
-      typedef _TFilter                        Superclass;
-      typedef _TMarksInterface                TMarksInterface;
-      typedef _TSeedsInterface                TSeedsInterface;
-      typedef itk::SmartPointer< Self >       Pointer;
-      typedef itk::SmartPointer< const Self > ConstPointer;
-
-      typedef typename _TSeedsInterface::TInputValue  TInputValue;
-      typedef typename _TSeedsInterface::TOutputValue TOutputValue;
-      typedef typename _TSeedsInterface::TNode        TNode;
-      typedef typename _TSeedsInterface::TNodes       TNodes;
-      typedef typename _TSeedsInterface::TSeeds       TSeeds;
-      typedef typename _TSeedsInterface::TVertex      TVertex;
-
-      typedef std::vector< TVertex > TNeighborhood;
+      typedef _TTraits                          TTraits;
+      typedef typename TTraits::TFilter         Superclass;
+      typedef typename TTraits::TMarksInterface TMarksInterface;
+      typedef typename TTraits::TSeedsInterface TSeedsInterface;
+      typedef Algorithm                         Self;
+      typedef itk::SmartPointer< Self >         Pointer;
+      typedef itk::SmartPointer< const Self >   ConstPointer;
+
+      typedef typename TTraits::TInputValue   TInputValue;
+      typedef typename TTraits::TOutputValue  TOutputValue;
+      typedef typename TTraits::TNeighborhood TNeighborhood;
+      typedef typename TTraits::TNode         TNode;
+      typedef typename TTraits::TNodes        TNodes;
+      typedef typename TTraits::TSeeds        TSeeds;
+      typedef typename TTraits::TVertex       TVertex;
 
       /**
        */
index 26729aaa37e77fdad63c16d4d207fa7bf66e9ba7..68296bebba6393585839f81f02b9cfd2e4546548 100644 (file)
@@ -7,16 +7,16 @@
 #define __fpa__Base__Algorithm__hxx__
 
 // -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::TEvent::
+template< class _TTraits >
+fpa::Base::Algorithm< _TTraits >::TEvent::
 TEvent( )
   : Superclass( )
 {
 }
 
 // -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::TEvent::
+template< class _TTraits >
+fpa::Base::Algorithm< _TTraits >::TEvent::
 TEvent( const TVertex& v, unsigned long fid, bool intoq )
   : Superclass( ),
     Vertex( v ),
@@ -26,42 +26,39 @@ TEvent( const TVertex& v, unsigned long fid, bool intoq )
 }
 
 // -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::TEvent::
+template< class _TTraits >
+fpa::Base::Algorithm< _TTraits >::TEvent::
 ~TEvent( )
 {
 }
 
 // -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-const char* 
-fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::TEvent::
+template< class _TTraits >
+const char* fpa::Base::Algorithm< _TTraits >::TEvent::
 GetEventName( ) const
 {
-  return( "fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::TEvent" );
+  return( "fpa::Base::Algorithm< _TTraits >::TEvent" );
 }
 
 // -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-bool
-fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::TEvent::
+template< class _TTraits >
+bool fpa::Base::Algorithm< _TTraits >::TEvent::
 CheckEvent( const itk::EventObject* e ) const
 {
   return( dynamic_cast< const Self* >( e ) != NULL );
 }
 
 // -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-itk::EventObject* 
-fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::TEvent::
+template< class _TTraits >
+itk::EventObject* fpa::Base::Algorithm< _TTraits >::TEvent::
 MakeObject( ) const
 {
   return( new Self );
 }
 
 // -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-void fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+void fpa::Base::Algorithm< _TTraits >::
 InvokeEvent( const itk::EventObject& e )
 {
   TEvent a;
@@ -75,8 +72,8 @@ InvokeEvent( const itk::EventObject& e )
 }
 
 // -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-void fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+void fpa::Base::Algorithm< _TTraits >::
 InvokeEvent( const itk::EventObject& e ) const
 {
   TEvent a;
@@ -90,26 +87,26 @@ InvokeEvent( const itk::EventObject& e ) const
 }
 
 // -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+fpa::Base::Algorithm< _TTraits >::
 Algorithm( )
   : Superclass( ),
-    _TMarksInterface( this ),
-    _TSeedsInterface( this ),
+    TMarksInterface( this ),
+    TSeedsInterface( this ),
     m_VisualDebug( false )
 {
 }
 
 // -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+fpa::Base::Algorithm< _TTraits >::
 ~Algorithm( )
 {
 }
 
 // -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-void fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+void fpa::Base::Algorithm< _TTraits >::
 GenerateData( )
 {
   this->InvokeEvent( itk::StartEvent( ) );
@@ -190,29 +187,29 @@ GenerateData( )
 }
 
 // -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-void fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+void fpa::Base::Algorithm< _TTraits >::
 _BeforeGenerateData( )
 {
 }
 
 // -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-void fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+void fpa::Base::Algorithm< _TTraits >::
 _AfterGenerateData( )
 {
 }
 
 // -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-void fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+void fpa::Base::Algorithm< _TTraits >::
 _FinishOneLoop( )
 {
 }
 
 // -------------------------------------------------------------------------
-template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
-void fpa::Base::Algorithm< _TFilter, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+void fpa::Base::Algorithm< _TTraits >::
 _QueueInit( )
 {
   this->_QueueClear( );
index 58dc5eee8c1649e1fd5bba48bc623036593d6e19..1c84a7253532bd69f72d2ec89b6aafddeada40ca 100644 (file)
@@ -17,33 +17,51 @@ namespace fpa
   {
     /**
      */
-    template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
+    template< class _TTraits >
     class Algorithm
-      : public fpa::Base::Algorithm< itk::ImageToImageFilter< _TInputImage, _TOutputImage >, _TMarksInterface, _TSeedsInterface >
+      : public fpa::Base::Algorithm< _TTraits >
     {
     public:
-      typedef _TInputImage     TInputImage;
-      typedef _TOutputImage    TOutputImage;
-      typedef _TMarksInterface TMarksInterface;
-      typedef _TSeedsInterface TSeedsInterface;
-      typedef itk::ImageToImageFilter< TInputImage, TOutputImage > TFilter;
-
-      typedef Algorithm Self;
-      typedef fpa::Base::Algorithm< TFilter, TMarksInterface, TSeedsInterface > Superclass;
-      typedef itk::SmartPointer< Self >       Pointer;
-      typedef itk::SmartPointer< const Self > ConstPointer;
-
-      typedef typename TInputImage::PixelType    TInputValue;
-      typedef typename TOutputImage::PixelType   TOutputValue;
-      typedef typename Superclass::TFrontId      TFrontId;
-      typedef typename Superclass::TNeighborhood TNeighborhood;
-      typedef typename Superclass::TNode         TNode;
-      typedef typename Superclass::TNodes        TNodes;
-      typedef typename Superclass::TSeeds        TSeeds;
-      typedef typename Superclass::TVertex       TVertex;
-      typedef typename Superclass::TPoint        TPoint;
-
-      typedef itk::Image< TFrontId, TInputImage::ImageDimension > TMarks;
+      typedef _TTraits TTraits;
+      typedef fpa::Base::Algorithm< _TTraits > Superclass;
+      typedef Algorithm                        Self;
+      typedef itk::SmartPointer< Self >        Pointer;
+      typedef itk::SmartPointer< const Self >  ConstPointer;
+
+      typedef typename TTraits::TFrontId      TFrontId;
+      typedef typename TTraits::TInputImage   TInputImage;
+      typedef typename TTraits::TInputValue   TInputValue;
+      typedef typename TTraits::TNeighborhood TNeighborhood;
+      typedef typename TTraits::TNode         TNode;
+      typedef typename TTraits::TNodes        TNodes;
+      typedef typename TTraits::TOutputImage  TOutputImage;
+      typedef typename TTraits::TOutputValue  TOutputValue;
+      typedef typename TTraits::TSeeds        TSeeds;
+      typedef typename TTraits::TVertex       TVertex;
+
+      typedef itk::Image< TFrontId, TTraits::Dimension > TMarks;
+
+      /* TODO
+         typedef _TMarksInterface TMarksInterface;
+         typedef _TSeedsInterface TSeedsInterface;
+
+         typedef typename TSeedsInterface::TTraits TTraits;
+         typedef typename TTraits::TInputImage   TInputImage;
+         typedef typename TTraits::TOutputImage  TOutputImage;
+         typedef typename TTraits::TInputValue   TInputValue;
+         typedef typename TTraits::TOutputValue  TOutputValue;
+         typedef typename TTraits::TFrontId      TFrontId;
+         typedef typename TTraits::TNeighborhood TNeighborhood;
+         typedef typename TTraits::TNode         TNode;
+         typedef typename TTraits::TNodes        TNodes;
+         typedef typename TTraits::TSeeds        TSeeds;
+         typedef typename TTraits::TVertex       TVertex;
+         typedef typename TTraits::TPoint        TPoint;
+
+         typedef itk::ImageToImageFilter< TInputImage, TOutputImage > TFilter;
+         typedef fpa::Base::Algorithm< TFilter, TMarksInterface, TSeedsInterface > Superclass;
+         typedef Algorithm                       Self;
+      */
 
     public:
       itkTypeMacro( fpa::Image::Algorithm, fpa::Base::Algorithm );
index 0fce0d597c85d14e51aa516b883ee351a6b87df1..43ebeb0af9da0affc72c892300b2d5ee6e7b3f9d 100644 (file)
@@ -7,11 +7,9 @@
 #define __fpa__Image__Algorithm__hxx__
 
 // -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
-typename
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
-TMarks*
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+typename fpa::Image::Algorithm< _TTraits >::TMarks*
+fpa::Image::Algorithm< _TTraits >::
 GetMarks( )
 {
   return(
@@ -22,11 +20,9 @@ GetMarks( )
 }
 
 // -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
-const typename
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
-TMarks*
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+const typename fpa::Image::Algorithm< _TTraits >::TMarks*
+fpa::Image::Algorithm< _TTraits >::
 GetMarks( ) const
 {
   return(
@@ -37,8 +33,8 @@ GetMarks( ) const
 }
 
 // -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+fpa::Image::Algorithm< _TTraits >::
 Algorithm( )
   : Superclass( ),
     m_NeigborhoodOrder( 1 )
@@ -49,17 +45,16 @@ Algorithm( )
 }
 
 // -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+fpa::Image::Algorithm< _TTraits >::
 ~Algorithm( )
 {
 }
 
 // -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
-typename
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
-TNodes fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+typename fpa::Image::Algorithm< _TTraits >::TNodes
+fpa::Image::Algorithm< _TTraits >::
 _UnifySeeds( )
 {
   const TInputImage* input = this->GetInput( );
@@ -95,9 +90,8 @@ _UnifySeeds( )
 }
 
 // -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
-void
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+void fpa::Image::Algorithm< _TTraits >::
 _ConfigureOutput( const TOutputValue& v )
 {
   const TInputImage* in = this->GetInput( );
@@ -124,10 +118,9 @@ _ConfigureOutput( const TOutputValue& v )
 }
 
 // -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
-typename
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
-TNeighborhood fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+typename fpa::Image::Algorithm< _TTraits >::TNeighborhood
+fpa::Image::Algorithm< _TTraits >::
 _GetNeighbors( const TVertex& v ) const
 {
   typename TInputImage::RegionType region =
@@ -157,57 +150,50 @@ _GetNeighbors( const TVertex& v ) const
 }
 
 // -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
-typename
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
-TInputValue
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+typename fpa::Image::Algorithm< _TTraits >::TInputValue
+fpa::Image::Algorithm< _TTraits >::
 _GetInputValue( const TVertex& v ) const
 {
   return( this->GetInput( )->GetPixel( v ) );
 }
 
 // -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
-typename
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
-TOutputValue fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+typename fpa::Image::Algorithm< _TTraits >::TOutputValue
+fpa::Image::Algorithm< _TTraits >::
 _GetOutputValue( const TVertex& v ) const
 {
   return( this->GetOutput( )->GetPixel( v ) );
 }
 
 // -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
-void
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+void fpa::Image::Algorithm< _TTraits >::
 _UpdateOutputValue( TNode& n )
 {
   this->GetOutput( )->SetPixel( n.Vertex, n.Value );
 }
 
 // -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
-bool
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+bool fpa::Image::Algorithm< _TTraits >::
 _IsMarked( const TVertex& v ) const
 {
   return( this->GetMarks( )->GetPixel( v ) > 0 );
 }
 
 // -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
-unsigned long
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+unsigned long fpa::Image::Algorithm< _TTraits >::
 _GetMark( const TVertex& v ) const
 {
   return( ( unsigned long )( this->GetMarks( )->GetPixel( v ) ) );
 }
 
 // -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
-void
-fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
+template< class _TTraits >
+void fpa::Image::Algorithm< _TTraits >::
 _Mark( const TVertex& v, unsigned long frontId )
 {
   this->GetMarks( )->SetPixel( v, TFrontId( frontId ) );
diff --git a/lib/fpa/Image/DefaultTraits.h b/lib/fpa/Image/DefaultTraits.h
new file mode 100644 (file)
index 0000000..c2b8295
--- /dev/null
@@ -0,0 +1,69 @@
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+
+#ifndef __fpa__Image__DefaultTraits__h__
+#define __fpa__Image__DefaultTraits__h__
+
+#include <vector>
+#include <itkConceptChecking.h>
+#include <itkImageToImageFilter.h>
+
+#include <fpa/Base/MarksInterfaceWithCollisions.h>
+#include <fpa/Base/SeedsInterface.h>
+
+namespace fpa
+{
+  namespace Image
+  {
+    /**
+     */
+    template< class _TInputImage, class _TOutputImage, class _TFrontId >
+    class DefaultTraits
+    {
+    public:
+      typedef DefaultTraits Self;
+      typedef _TInputImage  TInputImage;
+      typedef _TOutputImage TOutputImage;
+      typedef _TFrontId     TFrontId;
+      itkStaticConstMacro( Dimension, unsigned int, TInputImage::ImageDimension );
+
+      typedef typename TInputImage::IndexType        TVertex;
+      typedef typename TInputImage::PixelType        TInputValue;
+      typedef typename TInputImage::PointType        TPoint;
+      typedef typename TOutputImage::PixelType       TOutputValue;
+      typedef typename TVertex::LexicographicCompare TCompare;
+
+      typedef std::vector< TVertex > TNeighborhood;
+
+      typedef fpa::Base::SeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TCompare > TSeedsInterface;
+      typedef fpa::Base::MarksInterfaceWithCollisions< TVertex > TMarksInterface;
+      typedef itk::ImageToImageFilter< TInputImage, TOutputImage > TFilter;
+
+      typedef typename TSeedsInterface::TNode  TNode;
+      typedef typename TSeedsInterface::TNodes TNodes;
+      typedef typename TSeedsInterface::TSeed  TSeed;
+      typedef typename TSeedsInterface::TSeeds TSeeds;
+
+    public:
+      itkConceptMacro(
+        Check_SameDimension,
+        ( itk::Concept::SameDimension< TInputImage::ImageDimension, TOutputImage::ImageDimension > )
+        );
+
+    private:
+      // Purposely not implemented.
+      DefaultTraits( );
+      DefaultTraits( const Self& other );
+      virtual ~DefaultTraits( );
+      Self& operator=( const Self& other );
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __fpa__Image__DefaultTraits__h__
+
+// eof - $RCSfile$
index 6882bfea2c245c2fb76031361ed0f62e4d66f81d..d755ebfa8698bc1f1bf01a51403489d87da677a3 100644 (file)
@@ -7,11 +7,9 @@
 #define __fpa__Image__Dijkstra__h__
 
 #include <fpa/Base/Dijkstra.h>
-#include <fpa/Base/MarksInterfaceWithCollisions.h>
-#include <fpa/Base/SeedsInterface.h>
 #include <fpa/Image/Algorithm.h>
+#include <fpa/Image/DefaultTraits.h>
 #include <fpa/Image/MinimumSpanningTree.h>
-#include <fpa/Image/Functors/Dijkstra/Identity.h>
 
 namespace fpa
 {
@@ -21,73 +19,28 @@ namespace fpa
      */
     template< class _TInputImage, class _TOutputImage, class _TFrontId = unsigned char >
     class Dijkstra
-      : public fpa::Base::Dijkstra< fpa::Image::Algorithm< _TInputImage, _TOutputImage, fpa::Base::MarksInterfaceWithCollisions< typename _TInputImage::IndexType >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, typename _TOutputImage::PixelType, _TFrontId, typename _TInputImage::IndexType::LexicographicCompare > >, fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > >
+      : public fpa::Base::Dijkstra< fpa::Image::Algorithm< fpa::Image::DefaultTraits< _TInputImage, _TOutputImage, _TFrontId > >, fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > >
     {
     public:
       typedef _TInputImage  TInputImage;
       typedef _TOutputImage TOutputImage;
       typedef _TFrontId     TFrontId;
+      typedef fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > TMST;
 
-      typedef typename TInputImage::IndexType        TVertex;
-      typedef typename TInputImage::PointType        TPoint;
-      typedef typename TVertex::LexicographicCompare TVertexCompare;
-      typedef typename TInputImage::PixelType        TInputValue;
-      typedef typename TOutputImage::PixelType       TOutputValue;
-
-      typedef fpa::Base::MarksInterfaceWithCollisions< TVertex > TMarksInterface;
-      typedef fpa::Base::SeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TVertexCompare > TSeedsInterface;
-      typedef fpa::Image::Algorithm< TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm;
-      typedef fpa::Image::MinimumSpanningTree< TInputImage::ImageDimension > TMST;
-
-      typedef Dijkstra                                Self;
+      typedef fpa::Image::DefaultTraits< TInputImage, TOutputImage, TFrontId > TTraits;
+      typedef fpa::Image::Algorithm< TTraits >        TAlgorithm;
       typedef fpa::Base::Dijkstra< TAlgorithm, TMST > Superclass;
+      typedef Dijkstra                                Self;
       typedef itk::SmartPointer< Self >               Pointer;
       typedef itk::SmartPointer< const Self >         ConstPointer;
 
-      typedef fpa::Image::Functors::Dijkstra::Function< TInputImage, TOutputValue > TWeightFunction;
-
     public:
       itkNewMacro( Self );
       itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra );
 
     protected:
-      Dijkstra( )
-        : Superclass( )
-        {
-          typedef fpa::Image::Functors::Dijkstra::Identity< TInputImage, TOutputValue > _TDefaultFunction;
-          this->SetWeightFunction( _TDefaultFunction::New( ) );
-        }
-      virtual ~Dijkstra( )
-        {
-        }
-
-      virtual void _ConfigureOutput( const TOutputValue& v ) override
-        {
-          this->Superclass::_ConfigureOutput( v );
-          const TInputImage* in = this->GetInput( );
-
-          TMST* mst = this->GetMinimumSpanningTree( );
-          mst->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) );
-          mst->SetRequestedRegion( in->GetRequestedRegion( ) );
-          mst->SetBufferedRegion( in->GetBufferedRegion( ) );
-          mst->SetSpacing( in->GetSpacing( ) );
-          mst->SetOrigin( in->GetOrigin( ) );
-          mst->SetDirection( in->GetDirection( ) );
-          mst->Allocate( );
-
-          typename TMST::PixelType zero;
-          zero.Fill( 0 );
-          mst->FillBuffer( zero );
-        }
-
-      virtual void _BeforeGenerateData( ) override
-        {
-          this->Superclass::_BeforeGenerateData( );
-          TWeightFunction* wf =
-            dynamic_cast< TWeightFunction* >( this->GetWeightFunction( ) );
-          if( wf != NULL )
-            wf->SetImage( this->GetInput( ) );
-        }
+      Dijkstra( ) : Superclass( ) { }
+      virtual ~Dijkstra( )        { }
 
     private:
       // Purposely not implemented.
index 550864d7957de297a6f65bed47e84716af5903fb..7e6b0e032ce1f779d763893c3600f1010ff1916a 100644 (file)
@@ -10,6 +10,7 @@
 #include <fpa/Base/MarksInterface.h>
 #include <fpa/Base/SingleSeedInterface.h>
 #include <fpa/Image/Algorithm.h>
+#include <fpa/Image/DefaultTraits.h>
 
 namespace fpa
 {
@@ -18,32 +19,58 @@ namespace fpa
     /**
      */
     template< class _TInputImage, class _TOutputImage >
-    class Mori
-      : public fpa::Base::Mori< fpa::Image::Algorithm< _TInputImage, _TOutputImage, fpa::Base::MarksInterface< typename _TInputImage::IndexType >, fpa::Base::SingleSeedInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, typename _TOutputImage::PixelType, typename _TOutputImage::PixelType, typename _TInputImage::IndexType::LexicographicCompare > > >
+    class MoriTraits
+      : public fpa::Image::DefaultTraits< _TInputImage, _TOutputImage, typename _TOutputImage::PixelType >
     {
     public:
+      typedef MoriTraits    Self;
       typedef _TInputImage  TInputImage;
       typedef _TOutputImage TOutputImage;
+      typedef typename TOutputImage::PixelType TFrontId;
+      typedef fpa::Image::DefaultTraits< TInputImage, TOutputImage, TFrontId > Superclass;
+
+      typedef typename Superclass::TVertex       TVertex;
+      typedef typename Superclass::TInputValue   TInputValue;
+      typedef typename Superclass::TPoint        TPoint;
+      typedef typename Superclass::TOutputValue  TOutputValue;
+      typedef typename Superclass::TCompare      TCompare;
+      typedef typename Superclass::TNeighborhood TNeighborhood;
+      typedef typename Superclass::TFilter       TFilter;
+
+      typedef fpa::Base::SingleSeedInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TCompare > TSeedsInterface;
+      typedef fpa::Base::MarksInterface< TVertex > TMarksInterface;
 
-      typedef typename TInputImage::IndexType        TVertex;
-      typedef typename TInputImage::PointType        TPoint;
-      typedef typename TVertex::LexicographicCompare TVertexCompare;
-      typedef typename TInputImage::PixelType        TInputValue;
-      typedef typename TOutputImage::PixelType       TOutputValue;
-      typedef typename TOutputImage::PixelType       TFrontId;
+      typedef typename TSeedsInterface::TNode  TNode;
+      typedef typename TSeedsInterface::TNodes TNodes;
+      typedef typename TSeedsInterface::TSeed  TSeed;
+      typedef typename TSeedsInterface::TSeeds TSeeds;
 
-      typedef fpa::Base::MarksInterface< TVertex > TMarksInterface;
-      typedef fpa::Base::SingleSeedInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TVertexCompare > TSeedsInterface;
-      typedef fpa::Image::Algorithm< TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm;
+    private:
+      // Purposely not implemented.
+      MoriTraits( );
+      MoriTraits( const Self& other );
+      virtual ~MoriTraits( );
+      Self& operator=( const Self& other );
+    };
+
+    /**
+     */
+    template< class _TInputImage, class _TOutputImage >
+    class Mori
+      : public fpa::Base::Mori< fpa::Image::Algorithm< fpa::Image::MoriTraits< _TInputImage, _TOutputImage > > >
+    {
+    public:
+      typedef _TInputImage  TInputImage;
+      typedef _TOutputImage TOutputImage;
+      typedef fpa::Image::MoriTraits< TInputImage, TOutputImage > TTraits;
+      typedef fpa::Image::Algorithm< TTraits >                 TAlgorithm;
 
       typedef Mori                            Self;
       typedef fpa::Base::Mori< TAlgorithm >   Superclass;
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef typename TSeedsInterface::TNode  TNode;
-      typedef typename TSeedsInterface::TNodes TNodes;
-      typedef typename TAlgorithm::TMarks      TMarks;
+      typedef typename TAlgorithm::TMarks TMarks;
 
     public:
       itkNewMacro( Self );
index 5438f007b992133bc021ebd451fd015568ff0d0c..aba7d84ba14075b94fe667ea52f89736d7ba4323 100644 (file)
@@ -7,12 +7,11 @@
 #define __fpa__Image__RandomWalker__h__
 
 #include <itkImage.h>
-
 #include <fpa/Base/DijkstraBase.h>
 #include <fpa/Base/MarksInterface.h>
 #include <fpa/Image/Algorithm.h>
+#include <fpa/Image/DefaultTraits.h>
 #include <fpa/Image/LabelledSeedsInterface.h>
-#include <fpa/Image/Functors/Dijkstra/Function.h>
 
 namespace fpa
 {
@@ -21,32 +20,81 @@ namespace fpa
     /**
      */
     template< class _TInputImage, class _TLabelImage, class _TScalar >
-    class RandomWalker
-      : public fpa::Base::DijkstraBase< fpa::Image::Algorithm< _TInputImage, itk::Image< _TScalar, _TInputImage::ImageDimension >, fpa::Base::MarksInterface< typename _TInputImage::IndexType >, fpa::Image::LabelledSeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, _TScalar, typename _TLabelImage::PixelType, typename _TInputImage::IndexType::LexicographicCompare > > >
+    class RandomWalkerTraits
+      : public fpa::Image::DefaultTraits< _TInputImage, itk::Image< _TScalar, _TInputImage::ImageDimension >, typename _TLabelImage::PixelType >
     {
     public:
-      typedef _TInputImage TInputImage;
-      typedef _TLabelImage TLabelImage;
-      typedef _TScalar     TScalar;
-      typedef typename TInputImage::IndexType        TVertex;
-      typedef typename TInputImage::PointType        TPoint;
-      typedef typename TVertex::LexicographicCompare TVertexCompare;
-      typedef typename TInputImage::PixelType        TInputValue;
-      typedef typename TLabelImage::PixelType        TFrontId;
-
+      typedef RandomWalkerTraits Self;
+      typedef _TInputImage       TInputImage;
+      typedef _TLabelImage       TLabelImage;
+      typedef _TScalar           TScalar;
+      typedef typename _TLabelImage::PixelType TFrontId;
       typedef itk::Image< TScalar, _TInputImage::ImageDimension > TOutputImage;
-      typedef fpa::Base::MarksInterface< TVertex > TMarksInterface;
-      typedef fpa::Image::LabelledSeedsInterface< TVertex, TPoint, TInputValue, _TScalar, TFrontId, TVertexCompare > TSeedsInterface;
-      typedef fpa::Image::Algorithm< _TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm;
+      typedef fpa::Image::DefaultTraits< TInputImage, TOutputImage, TFrontId > Superclass;
+
+      typedef typename Superclass::TVertex       TVertex;
+      typedef typename Superclass::TInputValue   TInputValue;
+      typedef typename Superclass::TPoint        TPoint;
+      typedef typename Superclass::TOutputValue  TOutputValue;
+      typedef typename Superclass::TCompare      TCompare;
+      typedef typename Superclass::TNeighborhood TNeighborhood;
+      typedef typename Superclass::TFilter       TFilter;
 
-      typedef RandomWalker                          Self;
-      typedef fpa::Base::DijkstraBase< TAlgorithm > Superclass;
-      typedef itk::SmartPointer< Self >             Pointer;
-      typedef itk::SmartPointer< const Self >       ConstPointer;
+      typedef fpa::Image::LabelledSeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TCompare > TSeedsInterface;
+      typedef fpa::Base::MarksInterface< TVertex > TMarksInterface;
 
-      typedef fpa::Image::Functors::Dijkstra::Function< TInputImage, TScalar > TWeightFunction;
       typedef typename TSeedsInterface::TNode  TNode;
       typedef typename TSeedsInterface::TNodes TNodes;
+      typedef typename TSeedsInterface::TSeed  TSeed;
+      typedef typename TSeedsInterface::TSeeds TSeeds;
+
+    public:
+      itkConceptMacro(
+        Check_SameDimension,
+        ( itk::Concept::SameDimension< TInputImage::ImageDimension, TLabelImage::ImageDimension > )
+        );
+
+    private:
+      // Purposely not implemented.
+      RandomWalkerTraits( );
+      RandomWalkerTraits( const Self& other );
+      virtual ~RandomWalkerTraits( );
+      Self& operator=( const Self& other );
+    };
+
+    /**
+     */
+    template< class _TInputImage, class _TLabelImage, class _TScalar >
+    class RandomWalker
+      : public fpa::Base::DijkstraBase< fpa::Image::Algorithm< fpa::Image::RandomWalkerTraits< _TInputImage, _TLabelImage, _TScalar > > >
+        /* TODO
+           : public fpa::Base::DijkstraBase< fpa::Image::Algorithm< _TInputImage, itk::Image< _TScalar, _TInputImage::ImageDimension >, fpa::Base::MarksInterface< typename _TInputImage::IndexType >, fpa::Image::LabelledSeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, _TScalar, typename _TLabelImage::PixelType, typename _TInputImage::IndexType::LexicographicCompare > > >
+        */
+    {
+    public:
+      /* TODO
+         typedef _TInputImage TInputImage;
+         typedef _TLabelImage TLabelImage;
+         typedef _TScalar     TScalar;
+         typedef typename TInputImage::IndexType        TVertex;
+         typedef typename TInputImage::PointType        TPoint;
+         typedef typename TVertex::LexicographicCompare TVertexCompare;
+         typedef typename TInputImage::PixelType        TInputValue;
+         typedef typename TLabelImage::PixelType        TFrontId;
+
+         typedef itk::Image< TScalar, _TInputImage::ImageDimension > TOutputImage;
+         typedef fpa::Base::MarksInterface< TVertex > TMarksInterface;
+         typedef fpa::Image::LabelledSeedsInterface< TVertex, TPoint, TInputValue, _TScalar, TFrontId, TVertexCompare > TSeedsInterface;
+         typedef fpa::Image::Algorithm< _TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm;
+         typedef RandomWalker                          Self;
+         typedef fpa::Base::DijkstraBase< TAlgorithm > Superclass;
+         typedef itk::SmartPointer< Self >             Pointer;
+         typedef itk::SmartPointer< const Self >       ConstPointer;
+
+         typedef fpa::Image::Functors::Dijkstra::Function< TInputImage, TScalar > TWeightFunction;
+         typedef typename TSeedsInterface::TNode  TNode;
+         typedef typename TSeedsInterface::TNodes TNodes;
+      */
 
     public:
       itkNewMacro( Self );
index 2deff2f637de9001588b0ddbd8bdf1e261188ee1..4d190dc09e32229afc33dc88da42c55333dbf202 100644 (file)
@@ -7,9 +7,8 @@
 #define __fpa__Image__RegionGrow__h__
 
 #include <fpa/Base/RegionGrow.h>
-#include <fpa/Base/MarksInterfaceWithCollisions.h>
-#include <fpa/Base/SeedsInterface.h>
 #include <fpa/Image/Algorithm.h>
+#include <fpa/Image/DefaultTraits.h>
 
 namespace fpa
 {
@@ -19,43 +18,27 @@ namespace fpa
      */
     template< class _TInputImage, class _TOutputImage, class _TFrontId = unsigned char >
     class RegionGrow
-      : public fpa::Base::RegionGrow< fpa::Image::Algorithm< _TInputImage, _TOutputImage, fpa::Base::MarksInterfaceWithCollisions< typename _TInputImage::IndexType >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, typename _TOutputImage::PixelType, _TFrontId, typename _TInputImage::IndexType::LexicographicCompare > > >
+      : public fpa::Base::RegionGrow< fpa::Image::Algorithm< fpa::Image::DefaultTraits< _TInputImage, _TOutputImage, _TFrontId > > >
     {
     public:
       typedef _TInputImage  TInputImage;
       typedef _TOutputImage TOutputImage;
       typedef _TFrontId     TFrontId;
 
-      typedef typename TInputImage::IndexType        TVertex;
-      typedef typename TInputImage::PointType        TPoint;
-      typedef typename TVertex::LexicographicCompare TVertexCompare;
-      typedef typename TInputImage::PixelType        TInputValue;
-      typedef typename TOutputImage::PixelType       TOutputValue;
-
-      typedef fpa::Base::MarksInterfaceWithCollisions< TVertex > TMarksInterface;
-      typedef fpa::Base::SeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TVertexCompare > TSeedsInterface;
-      typedef fpa::Image::Algorithm< TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm;
-
-      typedef RegionGrow                          Self;
+      typedef fpa::Image::DefaultTraits< TInputImage, TOutputImage, TFrontId > TTraits;
+      typedef fpa::Image::Algorithm< TTraits >    TAlgorithm;
       typedef fpa::Base::RegionGrow< TAlgorithm > Superclass;
+      typedef RegionGrow                          Self;
       typedef itk::SmartPointer< Self >           Pointer;
       typedef itk::SmartPointer< const Self >     ConstPointer;
 
-      typedef typename TSeedsInterface::TNode  TNode;
-      typedef typename TSeedsInterface::TNodes TNodes;
-
     public:
       itkNewMacro( Self );
       itkTypeMacro( fpa::Image::RegionGrow, fpa::Base::RegionGrow );
 
     protected:
-      RegionGrow( )
-        : Superclass( )
-        {
-        }
-      virtual ~RegionGrow( )
-        {
-        }
+      RegionGrow( ) : Superclass( ) { }
+      virtual ~RegionGrow( )        { }
 
     private:
       // Purposely not implemented.