]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Fri, 3 Mar 2017 16:49:42 +0000 (11:49 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Fri, 3 Mar 2017 16:49:42 +0000 (11:49 -0500)
52 files changed:
examples/CMakeLists.txt
examples/FastMarching_00.cxx [new file with mode: 0644]
lib/fpa/Base/Algorithm.h
lib/fpa/Base/Algorithm.hxx
lib/fpa/Base/Dijkstra.h
lib/fpa/Base/Dijkstra.hxx
lib/fpa/Base/DijkstraCostFunctionBase.h [deleted file]
lib/fpa/Base/FastMarching.h [new file with mode: 0644]
lib/fpa/Base/FastMarching.hxx [new file with mode: 0644]
lib/fpa/Base/Functors/RegionGrow/Base.h
lib/fpa/Base/Functors/RegionGrow/Tautology.h
lib/fpa/Base/Functors/VertexCostFunctionBase.h [new file with mode: 0644]
lib/fpa/Base/PriorityQueueAlgorithm.h [new file with mode: 0644]
lib/fpa/Base/PriorityQueueAlgorithm.hxx [new file with mode: 0644]
lib/fpa/Base/QueueAlgorithm.h [new file with mode: 0644]
lib/fpa/Base/QueueAlgorithm.hxx [new file with mode: 0644]
lib/fpa/Base/RegionGrow.h
lib/fpa/Base/RegionGrow.hxx
lib/fpa/Image/Algorithm.h
lib/fpa/Image/Algorithm.hxx
lib/fpa/Image/Dijkstra.h
lib/fpa/Image/Dijkstra.hxx
lib/fpa/Image/FastMarching.h [new file with mode: 0644]
lib/fpa/Image/FastMarching.hxx [new file with mode: 0644]
lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.h
lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.hxx
lib/fpa/Image/Functors/SimpleNeighborhood.h
lib/fpa/Image/Functors/SimpleNeighborhood.hxx
lib/fpa/Image/Functors/VertexCost.h [moved from lib/fpa/Image/Functors/SimpleDijkstraCost.h with 64% similarity]
lib/fpa/Image/Functors/VertexCost.hxx [moved from lib/fpa/Image/Functors/SimpleDijkstraCost.hxx with 64% similarity]
lib/fpa/Image/MoriRegionGrowHelper.h
lib/fpa/Image/RegionGrow.hxx
lib/fpa/Image/SkeletonFilter.hxx
lib/fpaInstances/BaseFilters.i [new file with mode: 0644]
lib/fpaInstances/CMakeLists.txt
lib/fpaInstances/DataObjects.i
lib/fpaInstances/Filters.i [deleted file]
lib/fpaInstances/ImageFilters.i [new file with mode: 0644]
lib/fpaInstances/ImageFunctors.i [new file with mode: 0644]
plugins/CMakeLists.txt
plugins/DijkstraFunctors/SimpleImageDijkstraCost.cxx
plugins/ImageAlgorithms/BaseFilter.cxx
plugins/ImageAlgorithms/BaseFilter.h
plugins/ImageAlgorithms/Dijkstra.cxx
plugins/ImageAlgorithms/FastMarching.cxx [new file with mode: 0644]
plugins/ImageAlgorithms/FastMarching.h [new file with mode: 0644]
plugins/ImageAlgorithms/ImageAlgorithms.i
plugins/ImageAlgorithms/MoriRegionGrow.cxx
plugins/ImageAlgorithms/RegionGrow.cxx
plugins/ImageAlgorithms/SkeletonFilter.cxx
plugins/RegionGrowFunctors/BinaryThreshold.cxx
plugins/RegionGrowFunctors/RegionGrowFunctors.i

index acb1bc5fc9d3be3a63d6e0a7d4c91b3708d34595..e6d93b88d0f5e43c7f6e7a99216e2a0896750822 100644 (file)
@@ -4,6 +4,7 @@ IF(BUILD_Examples)
   SET(
     _examples
     RegionGrow_00
+    FastMarching_00
     MoriRegionGrow_00
     Skeleton_00
     )
diff --git a/examples/FastMarching_00.cxx b/examples/FastMarching_00.cxx
new file mode 100644 (file)
index 0000000..41ed61e
--- /dev/null
@@ -0,0 +1,55 @@
+#include <itkImage.h>
+#include <itkImageFileWriter.h>
+#include <fpa/Image/FastMarching.h>
+
+// -------------------------------------------------------------------------
+typedef itk::Image< float, 2 >                     TImage;
+typedef fpa::Image::FastMarching< TImage, TImage > TFilter;
+typedef itk::ImageFileWriter< TImage >             TWriter;
+
+// -------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+  TImage::SizeType size;
+  size.Fill( 512 );
+
+  TImage::SpacingType spac;
+  spac[ 0 ] = 0.4;
+  spac[ 1 ] = 1.7;
+
+  TImage::Pointer input = TImage::New( );
+  input->SetRegions( size );
+  input->SetSpacing( spac );
+  input->Allocate( );
+  input->FillBuffer( 1 );
+
+  TImage::RegionType region = input->GetLargestPossibleRegion( );
+  TImage::PointType p0, p1, p2, p3, p4;
+  input->TransformIndexToPhysicalPoint( region.GetIndex( ), p0 );
+  input->TransformIndexToPhysicalPoint(
+    region.GetIndex( ) + region.GetSize( ), p1
+    );
+  p2 = ( p0.GetVectorFromOrigin( ) + p1.GetVectorFromOrigin( ) ) * 0.5;
+  p3 = ( p0.GetVectorFromOrigin( ) + p1.GetVectorFromOrigin( ) ) * 0.25;
+  p4 = ( p0.GetVectorFromOrigin( ) + p1.GetVectorFromOrigin( ) ) * 0.75;
+  TImage::IndexType s0, s1, s2;
+  input->TransformPhysicalPointToIndex( p2, s0 );
+  input->TransformPhysicalPointToIndex( p3, s1 );
+  input->TransformPhysicalPointToIndex( p4, s2 );
+
+  TFilter::Pointer filter = TFilter::New( );
+  filter->SetInput( input );
+  filter->AddSeed( s0, 0 );
+  filter->AddSeed( s1, 0 );
+  filter->AddSeed( s2, 0 );
+  filter->Update( );
+
+  TWriter::Pointer writer = TWriter::New( );
+  writer->SetInput( filter->GetOutput( ) );
+  writer->SetFileName( "FastMarching_00.mhd" );
+  writer->Update( );
+
+  return( 0 );
+}
+
+// eof - $RCSfile$
index 1a2394c3e270ea3a931f3f5f3fec12ddaf1e6035..6625467e29ae3c698b4a3d55d61ac9c6464a8649 100644 (file)
@@ -5,6 +5,7 @@
 #include <itkFunctionBase.h>
 #include <fpa/Config.h>
 #include <fpa/Base/Events.h>
+#include <fpa/Base/Functors/VertexCostFunctionBase.h>
 
 namespace fpa
 {
@@ -29,6 +30,8 @@ namespace fpa
       // Different functions
       typedef std::vector< TVertex >                      TNeighborhood;
       typedef itk::FunctionBase< TVertex, TNeighborhood > TNeighborhoodFunction;
+      typedef itk::FunctionBase< TOutput, TOutput >       TConversionFunction;
+      typedef fpa::Base::Functors::VertexCostFunctionBase< TVertex, TOutput > TVertexFunction;
 
       // Minigraph to represent collisions
       typedef std::pair< _TVertex, bool >   TCollision;
@@ -66,7 +69,16 @@ namespace fpa
       itkSetMacro( StopAtOneFront, bool );
 
       itkGetObjectMacro( NeighborhoodFunction, TNeighborhoodFunction );
+      itkGetObjectMacro( ConversionFunction, TConversionFunction );
+      itkGetObjectMacro( VertexFunction, TVertexFunction );
+
+      itkGetConstObjectMacro( NeighborhoodFunction, TNeighborhoodFunction );
+      itkGetConstObjectMacro( ConversionFunction, TConversionFunction );
+      itkGetConstObjectMacro( VertexFunction, TVertexFunction );
+
       itkSetObjectMacro( NeighborhoodFunction, TNeighborhoodFunction );
+      itkSetObjectMacro( ConversionFunction, TConversionFunction );
+      itkSetObjectMacro( VertexFunction, TVertexFunction );
 
     public:
       void ClearSeeds( );
@@ -90,12 +102,16 @@ namespace fpa
       virtual bool _ValidLoop( ) const;
       virtual void _UpdateCollisions( const TVertex& a, const TVertex& b );
 
+      virtual _TOutput _GetInputValue( const _TQueueNode& v, const _TQueueNode& p );
+
       virtual void _InitMarks( ) = 0;
       virtual void _InitResults( const TOutput& init_value ) = 0;
       virtual bool _IsMarked( const _TVertex& v ) const = 0;
       virtual void _Mark( const _TQueueNode& n ) = 0;
       virtual TFrontId _GetMark( const _TVertex& v ) const = 0;
       virtual void _UpdateResult( const _TQueueNode& n ) = 0;
+      virtual TOutput _GetResult( const _TVertex& v ) const = 0;
+      virtual unsigned int _GetNumberOfDimensions( ) const = 0;
 
       virtual bool _UpdateValue( _TQueueNode& v, const _TQueueNode& p ) = 0;
       virtual unsigned long _QueueSize( ) const = 0;
@@ -111,7 +127,11 @@ namespace fpa
     protected:
       _TOutput m_InitResult;
       bool m_StopAtOneFront;
+
       typename TNeighborhoodFunction::Pointer m_NeighborhoodFunction;
+      typename TConversionFunction::Pointer   m_ConversionFunction;
+      typename TVertexFunction::Pointer       m_VertexFunction;
+
       std::vector< _TQueueNode > m_Seeds;
       TCollisions m_Collisions;
       unsigned int m_NumberOfFronts;
index df7133661849ac07a07e034a18e45bbaf94be743..c29ff03e174791bea40b5155fab7e55f2526db72 100644 (file)
@@ -251,6 +251,19 @@ _UpdateCollisions( const TVertex& a, const TVertex& b )
   } // fi
 }
 
+// -------------------------------------------------------------------------
+template < class _TFilter, class _TVertex, class _TOutput >
+_TOutput fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
+_GetInputValue( const _TQueueNode& v, const _TQueueNode& p )
+{
+  _TOutput res = this->m_InitResult;
+  if( this->m_VertexFunction.IsNotNull( ) )
+    res = this->m_VertexFunction->Evaluate( v.Vertex, p.Vertex );
+  if( this->m_ConversionFunction.IsNotNull( ) )
+    res = this->m_ConversionFunction->Evaluate( res );
+  return( res );
+}
+
 #endif // __fpa__Base__Algorithm__hxx__
 
 // eof - $RCSfile$
index aa62f90bbe2dcd07eae54fd684c306d277f95c57..08c704e83b9b7d019eafd6904be1b68158d8e771 100644 (file)
@@ -1,10 +1,7 @@
 #ifndef __fpa__Base__Dijkstra__h__
 #define __fpa__Base__Dijkstra__h__
 
-#include <vector>
-#include <fpa/Config.h>
-#include <itkFunctionBase.h>
-#include <fpa/Base/DijkstraCostFunctionBase.h>
+#include <fpa/Base/PriorityQueueAlgorithm.h>
 
 namespace fpa
 {
@@ -14,40 +11,24 @@ namespace fpa
      */
     template< class _TSuperclass, class _TMST >
     class Dijkstra
-      : public _TSuperclass
+      : public fpa::Base::PriorityQueueAlgorithm< _TSuperclass >
     {
     public:
-      typedef Dijkstra                        Self;
-      typedef _TSuperclass                    Superclass;
-      typedef itk::SmartPointer< Self >       Pointer;
-      typedef itk::SmartPointer< const Self > ConstPointer;
+      typedef Dijkstra                                          Self;
+      typedef fpa::Base::PriorityQueueAlgorithm< _TSuperclass > Superclass;
+      typedef itk::SmartPointer< Self >                         Pointer;
+      typedef itk::SmartPointer< const Self >                   ConstPointer;
 
       typedef _TMST TMST;
       typedef typename Superclass::TOutput TOutput;
       typedef typename Superclass::TVertex TVertex;
 
-      typedef itk::FunctionBase< TOutput, TOutput > TCostConversionFunction;
-      typedef DijkstraCostFunctionBase< TVertex, TOutput > TCostFunction;
-
     protected:
       typedef typename Superclass::_TQueueNode _TQueueNode;
-      struct _TQueueNodeCompare
-      {
-        bool operator( )( const _TQueueNode& a, const _TQueueNode& b )
-          {
-            return( b.Result < a.Result );
-          }
-      };
-      typedef std::vector< _TQueueNode > _TQueue;
 
     public:
       itkTypeMacro( Dijkstra, Algorithm );
 
-      itkGetObjectMacro( CostFunction, TCostFunction );
-      itkGetObjectMacro( CostConversionFunction, TCostConversionFunction );
-      itkSetObjectMacro( CostFunction, TCostFunction );
-      itkSetObjectMacro( CostConversionFunction, TCostConversionFunction );
-
     public:
       _TMST* GetMinimumSpanningTree( );
       const _TMST* GetMinimumSpanningTree( ) const;
@@ -62,10 +43,6 @@ namespace fpa
       virtual bool _UpdateValue(
         _TQueueNode& v, const _TQueueNode& p
         ) override;
-      virtual unsigned long _QueueSize( ) const override;
-      virtual void _QueueClear( ) override;
-      virtual void _QueuePush( const _TQueueNode& node ) override;
-      virtual _TQueueNode _QueuePop( ) override;
 
     private:
       // Purposely not defined
@@ -73,10 +50,6 @@ namespace fpa
       Self& operator=( const Self& other );
 
     protected:
-      _TQueue m_Queue;
-      typename TCostFunction::Pointer m_CostFunction;
-      typename TCostConversionFunction::Pointer m_CostConversionFunction;
-
       unsigned long m_MSTIndex;
     };
 
index 849ff6c981a9676c0c469734534ea58faad307a3..df9c75e5d07cbc994b5a4db3966bd879eabdfcc4 100644 (file)
@@ -75,9 +75,7 @@ template< class _TSuperclass, class _TMST >
 bool fpa::Base::Dijkstra< _TSuperclass, _TMST >::
 _UpdateValue( _TQueueNode& v, const _TQueueNode& p )
 {
-  v.Result = this->m_CostFunction->Evaluate( p.Vertex, v.Vertex );
-  if( this->m_CostConversionFunction.IsNotNull( ) )
-    v.Result = this->m_CostConversionFunction->Evaluate( v.Result );
+  v.Result = this->_GetInputValue( p.Vertex, v.Vertex );
   if( v.Result >= TOutput( 0 ) )
   {
     v.Result += p.Result;
@@ -91,45 +89,6 @@ _UpdateValue( _TQueueNode& v, const _TQueueNode& p )
   } // fi
 }
 
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-unsigned long fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_QueueSize( ) const
-{
-  return( this->m_Queue.size( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-void fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_QueueClear( )
-{
-  this->m_Queue.clear( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-void fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_QueuePush( const _TQueueNode& node )
-{
-  static _TQueueNodeCompare cmp;
-  this->m_Queue.push_back( node );
-  std::push_heap( this->m_Queue.begin( ), this->m_Queue.end( ), cmp );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSuperclass, class _TMST >
-typename fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_TQueueNode fpa::Base::Dijkstra< _TSuperclass, _TMST >::
-_QueuePop( )
-{
-  static _TQueueNodeCompare cmp;
-  std::pop_heap( this->m_Queue.begin( ), this->m_Queue.end( ), cmp );
-  _TQueueNode f = this->m_Queue.back( );
-  this->m_Queue.pop_back( );
-  return( f );
-}
-
 #endif // __fpa__Base__Dijkstra__hxx__
 
 // eof - $RCSfile$
diff --git a/lib/fpa/Base/DijkstraCostFunctionBase.h b/lib/fpa/Base/DijkstraCostFunctionBase.h
deleted file mode 100644 (file)
index d3a86b2..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef __fpa__Base__DijkstraCostFunctionBase__h__
-#define __fpa__Base__DijkstraCostFunctionBase__h__
-
-#include <itkObject.h>
-#include <itkObjectFactory.h>
-
-namespace fpa
-{
-  namespace Base
-  {
-    /**
-     */
-    template< class _TVertex, class _TOutput >
-    class DijkstraCostFunctionBase
-      : public itk::Object
-    {
-    public:
-      typedef DijkstraCostFunctionBase        Self;
-      typedef itk::Object                     Superclass;
-      typedef itk::SmartPointer< Self >       Pointer;
-      typedef itk::SmartPointer< const Self > ConstPointer;
-
-      typedef _TVertex TVertex;
-      typedef _TOutput TOutput;
-
-    public:
-      itkTypeMacro( DijkstraCostFunctionBase, itk::Object );
-
-    public:
-      virtual TOutput Evaluate( const TVertex& a, const TVertex& b ) const = 0;
-
-    protected:
-      DijkstraCostFunctionBase( )
-        : Superclass( )
-        { }
-      virtual ~DijkstraCostFunctionBase( )
-        { }
-
-    private:
-      // Purposely not defined
-      DijkstraCostFunctionBase( const Self& other );
-      Self& operator=( const Self& other );
-    };
-
-  } // ecapseman
-
-} // ecapseman
-
-#endif // __fpa__Base__DijkstraCostFunctionBase__h__
-
-// eof - $RCSfile$
diff --git a/lib/fpa/Base/FastMarching.h b/lib/fpa/Base/FastMarching.h
new file mode 100644 (file)
index 0000000..acea8e7
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef __fpa__Base__FastMarching__h__
+#define __fpa__Base__FastMarching__h__
+
+#include <fpa/Base/PriorityQueueAlgorithm.h>
+
+namespace fpa
+{
+  namespace Base
+  {
+    /**
+     */
+    template< class _TSuperclass >
+    class FastMarching
+      : public fpa::Base::PriorityQueueAlgorithm< _TSuperclass >
+    {
+    public:
+      typedef FastMarching                                      Self;
+      typedef fpa::Base::PriorityQueueAlgorithm< _TSuperclass > Superclass;
+      typedef itk::SmartPointer< Self >                         Pointer;
+      typedef itk::SmartPointer< const Self >                   ConstPointer;
+
+      typedef typename Superclass::TFrontId TFrontId;
+      typedef typename Superclass::TOutput  TOutput;
+      typedef typename Superclass::TVertex  TVertex;
+
+      typedef std::pair< TVertex, double >         TFastMarchingNeighbor;
+      typedef std::vector< TFastMarchingNeighbor > TFastMarchingNeighborhood;
+
+    protected:
+      typedef typename Superclass::_TQueueNode _TQueueNode;
+
+    public:
+      itkTypeMacro( FastMarching, Algorithm );
+
+    protected:
+      FastMarching( );
+      virtual ~FastMarching( );
+
+      virtual TFastMarchingNeighborhood _FastMarchingNeighbors( const TVertex& v ) const = 0;
+
+      virtual bool _UpdateValue( _TQueueNode& v, const _TQueueNode& p ) override;
+
+    private:
+      // Purposely not defined
+      FastMarching( const Self& other );
+      Self& operator=( const Self& other );
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Base/FastMarching.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Base__FastMarching__h__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Base/FastMarching.hxx b/lib/fpa/Base/FastMarching.hxx
new file mode 100644 (file)
index 0000000..61ec968
--- /dev/null
@@ -0,0 +1,81 @@
+#ifndef __fpa__Base__FastMarching__hxx__
+#define __fpa__Base__FastMarching__hxx__
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+fpa::Base::FastMarching< _TSuperclass >::
+FastMarching( )
+  : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+fpa::Base::FastMarching< _TSuperclass >::
+~FastMarching( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+bool fpa::Base::FastMarching< _TSuperclass >::
+_UpdateValue( _TQueueNode& v, const _TQueueNode& p )
+{
+  // Compute quadratic coefficients
+  double a = double( 0 );
+  double b = double( 0 );
+  double c = double( 0 );
+  TFastMarchingNeighborhood neighs = this->_FastMarchingNeighbors( v.Vertex );
+  for( unsigned int i = 0; i < neighs.size( ); i += 2 )
+  {
+    double tn = double( this->_GetResult( neighs[ i ].first ) );
+    double tp = double( this->_GetResult( neighs[ i + 1 ].first ) );
+    double dd = double( 0 );
+    double td = this->m_InitResult;
+    if( tn < tp )
+    {
+      td = tn;
+      dd = neighs[ i ].second;
+    }
+    else
+    {
+      td = tp;
+      dd = neighs[ i + 1 ].second;
+
+    } // fi
+
+    if( td < double( this->m_InitResult ) )
+    {
+      dd = double( 1 ) / ( dd * dd );
+      a += dd;
+      b += td * dd;
+      c += td * td * dd;
+
+    } // fi
+
+  } // rof
+  double F = double( this->_GetInputValue( v, p ) );
+  c -= double( 1 ) / ( F * F );
+
+  // Solve quadratic equation
+  double d = ( b * b ) - ( a * c );
+  if( d >= double( 0 ) )
+  {
+    d = std::sqrt( d );
+    b *= double( -1 );
+    double s1 = std::fabs( ( b + d ) / a );
+    double s2 = std::fabs( ( b - d ) / a );
+    v.Result = TOutput( ( s2 < s1 )? s1: s2 );
+    if( v.Result < this->_GetResult( v.Vertex ) )
+      this->_UpdateResult( v );
+  }
+  else
+  {
+    std::cout << "-----> " << v.Vertex << " " << d << std::endl;
+  }
+  return( true );
+}
+
+#endif // __fpa__Base__FastMarching__hxx__
+
+// eof - $RCSfile$
index 7daf46e53fc1ddd9ad48bf1834805f701e30b4a7..d2c37aae655ef17b808cf0f00516febad67f7c32 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <itkObject.h>
 #include <itkObjectFactory.h>
+#include <fpa/Base/Functors/VertexCostFunctionBase.h>
 
 namespace fpa
 {
@@ -14,29 +15,36 @@ namespace fpa
       {
         /**
          */
-        template< class _TVertex >
+        template< class _TVertex, class _TOutput >
         class Base
-          : public itk::Object
+          : public fpa::Base::Functors::VertexCostFunctionBase< _TVertex, _TOutput >
         {
         public:
+          typedef fpa::Base::Functors::VertexCostFunctionBase< _TVertex, _TOutput > Superclass;
           typedef Base                            Self;
-          typedef itk::Object                     Superclass;
           typedef itk::SmartPointer< Self >       Pointer;
           typedef itk::SmartPointer< const Self > ConstPointer;
 
           typedef _TVertex TVertex;
+          typedef _TOutput TOutput;
 
         public:
           itkTypeMacro( Base, itk::Object );
 
+          itkGetConstMacro( InsideValue, _TOutput );
+          itkGetConstMacro( OutsideValue, _TOutput );
+
+          itkSetMacro( InsideValue, _TOutput );
+          itkSetMacro( OutsideValue, _TOutput );
+
         public:
-          virtual bool Evaluate(
-            const TVertex& a, const TVertex& b
-            ) const = 0;
+          virtual TOutput Evaluate( const TVertex& a, const TVertex& b ) const = 0;
 
         protected:
           Base( )
-            : Superclass( )
+            : Superclass( ),
+              m_InsideValue( TOutput( 1 ) ),
+              m_OutsideValue( TOutput( 0 ) )
             { }
           virtual ~Base( )
             { }
@@ -45,6 +53,10 @@ namespace fpa
           // Purposely not defined
           Base( const Self& other );
           Self& operator=( const Self& other );
+
+        protected:
+          _TOutput m_InsideValue;
+          _TOutput m_OutsideValue;
         };
 
       } // ecapseman
index 744d618003e6635f259d3f1613d99acf7ec27339..11d016eccf149fb62792e760abdcc8d64364efe8 100644 (file)
@@ -13,16 +13,17 @@ namespace fpa
       {
         /**
          */
-        template< class _TVertex >
+        template< class _TVertex, class _TOutput >
         class Tautology
-          : public Base< _TVertex >
+          : public Base< _TVertex, _TOutput >
         {
         public:
           typedef Tautology                       Self;
-          typedef Base< _TVertex >                Superclass;
+          typedef Base< _TVertex, _TOutput >      Superclass;
           typedef itk::SmartPointer< Self >       Pointer;
           typedef itk::SmartPointer< const Self > ConstPointer;
 
+          typedef typename Superclass::TOutput TOutput;
           typedef typename Superclass::TVertex TVertex;
 
         public:
@@ -30,11 +31,9 @@ namespace fpa
           itkTypeMacro( Tautology, Base );
 
         public:
-          virtual bool Evaluate(
-            const TVertex& a, const TVertex& b
-            ) const override
+          virtual TOutput Evaluate( const TVertex& a, const TVertex& b ) const override
             {
-              return( true );
+              return( this->m_InsideValue );
             }
 
         protected:
diff --git a/lib/fpa/Base/Functors/VertexCostFunctionBase.h b/lib/fpa/Base/Functors/VertexCostFunctionBase.h
new file mode 100644 (file)
index 0000000..12f5c24
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef __fpa__Base__Functors__VertexCostFunctionBase__h__
+#define __fpa__Base__Functors__VertexCostFunctionBase__h__
+
+#include <itkObject.h>
+#include <itkObjectFactory.h>
+
+namespace fpa
+{
+  namespace Base
+  {
+    namespace Functors
+    {
+      /**
+       */
+      template< class _TVertex, class _TOutput >
+      class VertexCostFunctionBase
+        : public itk::Object
+      {
+      public:
+        typedef VertexCostFunctionBase          Self;
+        typedef itk::Object                     Superclass;
+        typedef itk::SmartPointer< Self >       Pointer;
+        typedef itk::SmartPointer< const Self > ConstPointer;
+
+        typedef _TVertex TVertex;
+        typedef _TOutput TOutput;
+
+      public:
+        itkTypeMacro( VertexCostFunctionBase, itk::Object );
+
+      public:
+        virtual TOutput Evaluate( const TVertex& a, const TVertex& b ) const = 0;
+
+      protected:
+        VertexCostFunctionBase( )
+          : Superclass( )
+          { }
+        virtual ~VertexCostFunctionBase( )
+          { }
+
+      private:
+        // Purposely not defined
+        VertexCostFunctionBase( const Self& other );
+        Self& operator=( const Self& other );
+      };
+
+    } // ecapseman
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __fpa__Base__Functors__VertexCostFunctionBase__h__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Base/PriorityQueueAlgorithm.h b/lib/fpa/Base/PriorityQueueAlgorithm.h
new file mode 100644 (file)
index 0000000..e34b823
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef __fpa__Base__PriorityQueueAlgorithm__h__
+#define __fpa__Base__PriorityQueueAlgorithm__h__
+
+#include <queue>
+
+namespace fpa
+{
+  namespace Base
+  {
+    /**
+     */
+    template< class _TSuperclass >
+    class PriorityQueueAlgorithm
+      : public _TSuperclass
+    {
+    public:
+      typedef PriorityQueueAlgorithm          Self;
+      typedef _TSuperclass                    Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
+
+    protected:
+      typedef typename Superclass::_TQueueNode _TQueueNode;
+      struct _TQueueNodeCompare
+      {
+        bool operator( )( const _TQueueNode& a, const _TQueueNode& b )
+          {
+            return( b.Result < a.Result );
+          }
+      };
+      typedef std::vector< _TQueueNode > _TQueue;
+
+    public:
+      itkTypeMacro( PriorityQueueAlgorithm, Algorithm );
+
+    protected:
+      PriorityQueueAlgorithm( );
+      virtual ~PriorityQueueAlgorithm( );
+
+      virtual unsigned long _QueueSize( ) const override;
+      virtual void _QueueClear( ) override;
+      virtual void _QueuePush( const _TQueueNode& node ) override;
+      virtual _TQueueNode _QueuePop( ) override;
+
+    private:
+      // Purposely not defined
+      PriorityQueueAlgorithm( const Self& other );
+      Self& operator=( const Self& other );
+
+    protected:
+      _TQueue m_Queue;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Base/PriorityQueueAlgorithm.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Base__PriorityQueueAlgorithm__h__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Base/PriorityQueueAlgorithm.hxx b/lib/fpa/Base/PriorityQueueAlgorithm.hxx
new file mode 100644 (file)
index 0000000..11c1408
--- /dev/null
@@ -0,0 +1,60 @@
+#ifndef __fpa__Base__PriorityQueueAlgorithm__hxx__
+#define __fpa__Base__PriorityQueueAlgorithm__hxx__
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+fpa::Base::PriorityQueueAlgorithm< _TSuperclass >::
+PriorityQueueAlgorithm( )
+  : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+fpa::Base::PriorityQueueAlgorithm< _TSuperclass >::
+~PriorityQueueAlgorithm( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+unsigned long fpa::Base::PriorityQueueAlgorithm< _TSuperclass >::
+_QueueSize( ) const
+{
+  return( this->m_Queue.size( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+void fpa::Base::PriorityQueueAlgorithm< _TSuperclass >::
+_QueueClear( )
+{
+  this->m_Queue.clear( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+void fpa::Base::PriorityQueueAlgorithm< _TSuperclass >::
+_QueuePush( const _TQueueNode& node )
+{
+  static _TQueueNodeCompare cmp;
+  this->m_Queue.push_back( node );
+  std::push_heap( this->m_Queue.begin( ), this->m_Queue.end( ), cmp );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+typename fpa::Base::PriorityQueueAlgorithm< _TSuperclass >::
+_TQueueNode fpa::Base::PriorityQueueAlgorithm< _TSuperclass >::
+_QueuePop( )
+{
+  static _TQueueNodeCompare cmp;
+  std::pop_heap( this->m_Queue.begin( ), this->m_Queue.end( ), cmp );
+  _TQueueNode f = this->m_Queue.back( );
+  this->m_Queue.pop_back( );
+  return( f );
+}
+
+#endif // __fpa__Base__PriorityQueueAlgorithm__hxx__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Base/QueueAlgorithm.h b/lib/fpa/Base/QueueAlgorithm.h
new file mode 100644 (file)
index 0000000..dd077f7
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef __fpa__Base__QueueAlgorithm__h__
+#define __fpa__Base__QueueAlgorithm__h__
+
+#include <queue>
+#include <itkMacro.h>
+#include <itkSmartPointer.h>
+
+namespace fpa
+{
+  namespace Base
+  {
+    /**
+     */
+    template< class _TSuperclass >
+    class QueueAlgorithm
+      : public _TSuperclass
+    {
+    public:
+      typedef QueueAlgorithm                  Self;
+      typedef _TSuperclass                    Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
+
+    protected:
+      typedef typename Superclass::_TQueueNode _TQueueNode;
+      typedef std::queue< _TQueueNode > _TQueue;
+
+    public:
+      itkTypeMacro( QueueAlgorithm, _TSuperclass );
+
+    protected:
+      QueueAlgorithm( );
+      virtual ~QueueAlgorithm( );
+
+      virtual unsigned long _QueueSize( ) const override;
+      virtual void _QueueClear( ) override;
+      virtual void _QueuePush( const _TQueueNode& node ) override;
+      virtual _TQueueNode _QueuePop( ) override;
+
+    private:
+      // Purposely not defined
+      QueueAlgorithm( const Self& other );
+      Self& operator=( const Self& other );
+
+    protected:
+      _TQueue m_Queue;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Base/QueueAlgorithm.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Base__QueueAlgorithm__h__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Base/QueueAlgorithm.hxx b/lib/fpa/Base/QueueAlgorithm.hxx
new file mode 100644 (file)
index 0000000..db5b8bc
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef __fpa__Base__QueueAlgorithm__hxx__
+#define __fpa__Base__QueueAlgorithm__hxx__
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+fpa::Base::QueueAlgorithm< _TSuperclass >::
+QueueAlgorithm( )
+  : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+fpa::Base::QueueAlgorithm< _TSuperclass >::
+~QueueAlgorithm( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+unsigned long fpa::Base::QueueAlgorithm< _TSuperclass >::
+_QueueSize( ) const
+{
+  return( this->m_Queue.size( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+void fpa::Base::QueueAlgorithm< _TSuperclass >::
+_QueueClear( )
+{
+  while( this->m_Queue.size( ) > 0 )
+    this->m_Queue.pop( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+void fpa::Base::QueueAlgorithm< _TSuperclass >::
+_QueuePush( const _TQueueNode& node )
+{
+  this->m_Queue.push( node );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+typename fpa::Base::QueueAlgorithm< _TSuperclass >::
+_TQueueNode fpa::Base::QueueAlgorithm< _TSuperclass >::
+_QueuePop( )
+{
+  _TQueueNode f = this->m_Queue.front( );
+  this->m_Queue.pop( );
+  return( f );
+}
+
+#endif // __fpa__Base__QueueAlgorithm__hxx__
+
+// eof - $RCSfile$
index a8fcc932aa5dbba92883bb983b872698ad52f4c6..6a3c9e6faebff789ed87514e7255bb5292eeaa74 100644 (file)
@@ -2,7 +2,7 @@
 #define __fpa__Base__RegionGrow__h__
 
 #include <queue>
-#include <fpa/Config.h>
+#include <fpa/Base/QueueAlgorithm.h>
 #include <fpa/Base/Functors/RegionGrow/Base.h>
 
 namespace fpa
@@ -13,33 +13,33 @@ namespace fpa
      */
     template< class _TSuperclass >
     class RegionGrow
-      : public _TSuperclass
+      : public fpa::Base::QueueAlgorithm< _TSuperclass >
     {
     public:
-      typedef RegionGrow                      Self;
-      typedef _TSuperclass                    Superclass;
-      typedef itk::SmartPointer< Self >       Pointer;
-      typedef itk::SmartPointer< const Self > ConstPointer;
+      typedef RegionGrow                                Self;
+      typedef fpa::Base::QueueAlgorithm< _TSuperclass > Superclass;
+      typedef itk::SmartPointer< Self >                 Pointer;
+      typedef itk::SmartPointer< const Self >           ConstPointer;
 
       typedef typename Superclass::TOutput TOutput;
       typedef typename Superclass::TVertex TVertex;
-
-      typedef fpa::Base::Functors::RegionGrow::Base< TVertex > TGrowFunction;
+      typedef fpa::Base::Functors::RegionGrow::Base< TVertex, TOutput > TGrowFunction;
 
     protected:
       typedef typename Superclass::_TQueueNode _TQueueNode;
-      typedef std::queue< _TQueueNode > _TQueue;
 
     public:
       itkTypeMacro( RegionGrow, Algorithm );
 
-      itkGetObjectMacro( GrowFunction, TGrowFunction );
-      itkGetConstMacro( InsideValue, TOutput );
-      itkGetConstMacro( OutsideValue, TOutput );
+    public:
+      TGrowFunction* GetGrowFunction( );
+      const TGrowFunction* GetGrowFunction( ) const;
+      TOutput GetInsideValue( ) const;
+      TOutput GetOutsideValue( ) const;
 
-      itkSetObjectMacro( GrowFunction, TGrowFunction );
-      itkSetMacro( InsideValue, TOutput );
-      itkSetMacro( OutsideValue, TOutput );
+      void SetGrowFunction( TGrowFunction* f );
+      void SetInsideValue( const TOutput& v );
+      void SetOutsideValue( const TOutput& v );
 
     protected:
       RegionGrow( );
@@ -48,21 +48,11 @@ namespace fpa
       virtual bool _UpdateValue(
         _TQueueNode& v, const _TQueueNode& p
         ) override;
-      virtual unsigned long _QueueSize( ) const override;
-      virtual void _QueueClear( ) override;
-      virtual void _QueuePush( const _TQueueNode& node ) override;
-      virtual _TQueueNode _QueuePop( ) override;
 
     private:
       // Purposely not defined
       RegionGrow( const Self& other );
       Self& operator=( const Self& other );
-
-    protected:
-      TOutput m_InsideValue;
-      TOutput m_OutsideValue;
-      _TQueue m_Queue;
-      typename TGrowFunction::Pointer m_GrowFunction;
     };
 
   } // ecapseman
index e7dba1fa3fbb6a7453846a2e00507352d5dec9d9..6865916c412b5771fb7270b67a2a4e14b6ea1f92 100644 (file)
 
 // -------------------------------------------------------------------------
 template< class _TSuperclass >
-fpa::Base::RegionGrow< _TSuperclass >::
-RegionGrow( )
-  : Superclass( ),
-    m_InsideValue( TOutput( 1 ) ),
-    m_OutsideValue( TOutput( 0 ) )
+typename fpa::Base::RegionGrow< _TSuperclass >::
+TGrowFunction* fpa::Base::RegionGrow< _TSuperclass >::
+GetGrowFunction( )
 {
-  this->m_InitResult = TOutput( 0 );
-  this->SetGrowFunction(
-    fpa::Base::Functors::RegionGrow::Tautology< TVertex >::New( )
+  return( dynamic_cast< TGrowFunction* >( this->GetVertexFunction( ) ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+const typename fpa::Base::RegionGrow< _TSuperclass >::
+TGrowFunction* fpa::Base::RegionGrow< _TSuperclass >::
+GetGrowFunction( ) const
+{
+  return(
+    dynamic_cast< const TGrowFunction* >( this->GetVertexFunction( ) )
     );
 }
 
 // -------------------------------------------------------------------------
 template< class _TSuperclass >
-fpa::Base::RegionGrow< _TSuperclass >::
-~RegionGrow( )
+typename fpa::Base::RegionGrow< _TSuperclass >::
+TOutput fpa::Base::RegionGrow< _TSuperclass >::
+GetInsideValue( ) const
 {
+  const TGrowFunction* f = this->GetGrowFunction( );
+  if( f != NULL )
+    return( f->GetInsideValue( ) );
+  else
+    return( this->m_InitResult );
 }
 
 // -------------------------------------------------------------------------
 template< class _TSuperclass >
-bool fpa::Base::RegionGrow< _TSuperclass >::
-_UpdateValue( _TQueueNode& v, const _TQueueNode& p )
+typename fpa::Base::RegionGrow< _TSuperclass >::
+TOutput fpa::Base::RegionGrow< _TSuperclass >::
+GetOutsideValue( ) const
 {
-  if( this->m_GrowFunction.IsNotNull( ) )
-  {
-    bool in = this->m_GrowFunction->Evaluate( p.Vertex, v.Vertex );
-    v.Result = ( in )? this->m_InsideValue: this->m_OutsideValue;
-    return( in );
-  }
+  const TGrowFunction* f = this->GetGrowFunction( );
+  if( f != NULL )
+    return( f->GetOutsideValue( ) );
   else
+    return( this->m_InitResult );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+void fpa::Base::RegionGrow< _TSuperclass >::
+SetGrowFunction( TGrowFunction* f )
+{
+  TGrowFunction* old_f = this->GetGrowFunction( );
+  if( old_f != NULL )
   {
-    v.Result = this->m_InitResult;
-    return( false );
+    f->SetInsideValue( old_f->GetInsideValue( ) );
+    f->SetOutsideValue( old_f->GetOutsideValue( ) );
 
   } // fi
+  this->SetVertexFunction( f );
 }
 
 // -------------------------------------------------------------------------
 template< class _TSuperclass >
-unsigned long fpa::Base::RegionGrow< _TSuperclass >::
-_QueueSize( ) const
+void fpa::Base::RegionGrow< _TSuperclass >::
+SetInsideValue( const TOutput& v )
 {
-  return( this->m_Queue.size( ) );
+  TGrowFunction* f = this->GetGrowFunction( );
+  if( f != NULL )
+  {
+    f->SetInsideValue( v );
+    this->Modified( );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
 template< class _TSuperclass >
 void fpa::Base::RegionGrow< _TSuperclass >::
-_QueueClear( )
+SetOutsideValue( const TOutput& v )
 {
-  while( this->m_Queue.size( ) > 0 )
-    this->m_Queue.pop( );
+  TGrowFunction* f = this->GetGrowFunction( );
+  if( f != NULL )
+  {
+    f->SetOutsideValue( v );
+    this->Modified( );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
 template< class _TSuperclass >
-void fpa::Base::RegionGrow< _TSuperclass >::
-_QueuePush( const _TQueueNode& node )
+fpa::Base::RegionGrow< _TSuperclass >::
+RegionGrow( )
+  : Superclass( )
 {
-  this->m_Queue.push( node );
+  typedef fpa::Base::Functors::RegionGrow::Tautology< TVertex, TOutput > _TFunc;
+  this->SetGrowFunction( _TFunc::New( ) );
+  this->m_InitResult = this->GetGrowFunction( )->GetOutsideValue( );
 }
 
 // -------------------------------------------------------------------------
 template< class _TSuperclass >
-typename fpa::Base::RegionGrow< _TSuperclass >::
-_TQueueNode fpa::Base::RegionGrow< _TSuperclass >::
-_QueuePop( )
+fpa::Base::RegionGrow< _TSuperclass >::
+~RegionGrow( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+bool fpa::Base::RegionGrow< _TSuperclass >::
+_UpdateValue( _TQueueNode& v, const _TQueueNode& p )
 {
-  _TQueueNode f = this->m_Queue.front( );
-  this->m_Queue.pop( );
-  return( f );
+  v.Result = this->_GetInputValue( v, p );
+  return( v.Result == this->GetInsideValue( ) );
 }
 
 #endif // __fpa__Base__RegionGrow__hxx__
index d613ce3d8afce33b090f781c9abc04df658cc9d5..0105cc3080d13166c0a23ca5b702b7622012c795 100644 (file)
@@ -28,7 +28,9 @@ namespace fpa
 
       typedef typename Superclass::TFrontId      TFrontId;
       typedef typename Superclass::TNeighborhood TNeighborhood;
-      typedef fpa::Image::Functors::Base< itk::ImageBase< _TInputImage::ImageDimension >, itk::FunctionBase< TVertex, TNeighborhood > > TNeighborhoodFunction;
+
+      typedef fpa::Image::Functors::Base< itk::ImageBase< _TInputImage::ImageDimension >, typename Superclass::TNeighborhoodFunction > TNeighborhoodFunction;
+      typedef fpa::Image::Functors::Base< _TInputImage, typename Superclass::TVertexFunction > TVertexFunction;
 
     protected:
       typedef typename Superclass::_TQueueNode _TQueueNode;
@@ -47,6 +49,8 @@ namespace fpa
       virtual void _Mark( const _TQueueNode& n ) override;
       virtual TFrontId _GetMark( const TVertex& v ) const override;
       virtual void _UpdateResult( const _TQueueNode& n ) override;
+      virtual TOutput _GetResult( const TVertex& v ) const override;
+      virtual unsigned int _GetNumberOfDimensions( ) const override;
 
     private:
       // Purposely not defined
index ed7342130ba2389b6c64bbbac1dfc3208259ae01..6e4eef139929c21ebb5fc22b182576067fde4b04 100644 (file)
@@ -12,8 +12,7 @@ fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
 Algorithm( )
   : Superclass( )
 {
-  typedef itk::ImageBase< _TInputImage::ImageDimension > _TImageBase;
-  typedef fpa::Image::Functors::SimpleNeighborhood< _TImageBase > _TNeigh;
+  typedef fpa::Image::Functors::SimpleNeighborhood< _TInputImage::ImageDimension > _TNeigh;
   typedef itk::Image< TFrontId, _TInputImage::ImageDimension > _TMarks;
 
   this->m_MarksIdx = this->GetNumberOfRequiredOutputs( );
@@ -47,6 +46,14 @@ _BeforeGenerateData( )
   if( neighFunc == NULL )
     itkExceptionMacro( << "NeighborhoodFunction not well defined." );
   neighFunc->SetImage( this->GetInput( ) );
+
+  TVertexFunction* vertexFunc =
+    dynamic_cast< TVertexFunction* >(
+      this->GetVertexFunction( )
+      );
+  if( vertexFunc == NULL )
+    itkExceptionMacro( << "VertexFunction not well defined." );
+  vertexFunc->SetImage( this->GetInput( ) );
 }
 
 // -------------------------------------------------------------------------
@@ -118,6 +125,26 @@ _UpdateResult( const _TQueueNode& n )
   this->GetOutput( )->SetPixel( n.Vertex, n.Result );
 }
 
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+typename fpa::Image::Algorithm< _TInputImage, _TOutputImage >::TOutput
+fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
+_GetResult( const TVertex& v ) const
+{
+  if( this->GetOutput( )->GetLargestPossibleRegion( ).IsInside( v ) )
+    return( this->GetOutput( )->GetPixel( v ) );
+  else
+    return( this->m_InitResult );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+unsigned int fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
+_GetNumberOfDimensions( ) const
+{
+  return( _TInputImage::ImageDimension );
+}
+
 #endif // __fpa__Image__Algorithm__hxx__
 
 // eof - $RCSfile$
index 96c642b273be7fce59a3d6f51bde113b3ed2f827..118cc27abc76593139574fc50b05d344e15a6006 100644 (file)
@@ -27,8 +27,6 @@ namespace fpa
       typedef typename Superclass::TOutput TOutput;
       typedef typename Superclass::TVertex TVertex;
 
-      typedef fpa::Image::Functors::Base< _TInputImage, fpa::Base::DijkstraCostFunctionBase< TVertex, TOutput > > TCostFunction;
-
     public:
       itkNewMacro( Self );
       itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra );
@@ -37,8 +35,6 @@ namespace fpa
       Dijkstra( );
       virtual ~Dijkstra( );
 
-      virtual void _BeforeGenerateData( ) override;
-
     private:
       // Purposely not defined
       Dijkstra( const Self& other );
index bf6b5f09d67f99382f012d75b129d0921adf12bc..1f21dc4335cddbe310c8fe5ef0e9d6ee65c1f9f2 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __fpa__Image__Dijkstra__hxx__
 #define __fpa__Image__Dijkstra__hxx__
 
-#include <fpa/Image/Functors/SimpleDijkstraCost.h>
+#include <fpa/Image/Functors/VertexCost.h>
 
 // -------------------------------------------------------------------------
 template< class _TInputImage, class _TOutputImage >
@@ -9,12 +9,9 @@ fpa::Image::Dijkstra< _TInputImage, _TOutputImage >::
 Dijkstra( )
   : Superclass( )
 {
-  typedef
-    fpa::Image::Functors::SimpleDijkstraCost< _TInputImage, TOutput >
-    _TCost;
-
+  typedef fpa::Image::Functors::VertexCost< _TInputImage, TOutput > _TCost;
   typename _TCost::Pointer cost = _TCost::New( );
-  this->SetCostFunction( cost );
+  this->SetVertexFunction( cost );
 }
 
 // -------------------------------------------------------------------------
@@ -24,20 +21,6 @@ fpa::Image::Dijkstra< _TInputImage, _TOutputImage >::
 {
 }
 
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputImage >
-void fpa::Image::Dijkstra< _TInputImage, _TOutputImage >::
-_BeforeGenerateData( )
-{
-  this->Superclass::_BeforeGenerateData( );
-
-  TCostFunction* cost =
-    dynamic_cast< TCostFunction* >( this->GetCostFunction( ) );
-  if( cost == NULL )
-    itkExceptionMacro( << "CostFunction not well defined." );
-  cost->SetImage( this->GetInput( ) );
-}
-
 #endif // __fpa__Image__Dijkstra__hxx__
 
 // eof - $RCSfile$
diff --git a/lib/fpa/Image/FastMarching.h b/lib/fpa/Image/FastMarching.h
new file mode 100644 (file)
index 0000000..2a4056f
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef __fpa__Image__FastMarching__h__
+#define __fpa__Image__FastMarching__h__
+
+#include <fpa/Base/FastMarching.h>
+#include <fpa/Image/Algorithm.h>
+
+namespace fpa
+{
+  namespace Image
+  {
+    /**
+     */
+    template< class _TInputImage, class _TOutputImage >
+    class FastMarching
+      : public fpa::Base::FastMarching< fpa::Image::Algorithm< _TInputImage, _TOutputImage > >
+    {
+    public:
+      typedef FastMarching                                         Self;
+      typedef fpa::Image::Algorithm< _TInputImage, _TOutputImage > TAlgorithm;
+      typedef fpa::Base::FastMarching< TAlgorithm > Superclass;
+      typedef itk::SmartPointer< Self >             Pointer;
+      typedef itk::SmartPointer< const Self >       ConstPointer;
+
+      typedef typename Superclass::TOutput TOutput;
+      typedef typename Superclass::TVertex TVertex;
+      typedef typename Superclass::TFastMarchingNeighbor TFastMarchingNeighbor;
+      typedef typename Superclass::TFastMarchingNeighborhood TFastMarchingNeighborhood;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( fpa::Image::FastMarching, fpa::Base::FastMarching );
+
+    protected:
+      FastMarching( );
+      virtual ~FastMarching( );
+
+      virtual TFastMarchingNeighborhood _FastMarchingNeighbors( const TVertex& v ) const override;
+
+    private:
+      // Purposely not defined
+      FastMarching( const Self& other );
+      Self& operator=( const Self& other );
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Image/FastMarching.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Image__FastMarching__h__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Image/FastMarching.hxx b/lib/fpa/Image/FastMarching.hxx
new file mode 100644 (file)
index 0000000..fe75b21
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef __fpa__Image__FastMarching__hxx__
+#define __fpa__Image__FastMarching__hxx__
+
+#include <fpa/Image/Functors/VertexCost.h>
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+fpa::Image::FastMarching< _TInputImage, _TOutputImage >::
+FastMarching( )
+  : Superclass( )
+{
+  typedef fpa::Image::Functors::VertexCost< _TInputImage, TOutput > _TCost;
+  typename _TCost::Pointer cost = _TCost::New( );
+  this->SetVertexFunction( cost );
+  this->m_InitResult = std::numeric_limits< TOutput >::max( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+fpa::Image::FastMarching< _TInputImage, _TOutputImage >::
+~FastMarching( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+typename fpa::Image::FastMarching< _TInputImage, _TOutputImage >::
+TFastMarchingNeighborhood
+fpa::Image::FastMarching< _TInputImage, _TOutputImage >::
+_FastMarchingNeighbors( const TVertex& v ) const
+{
+  TFastMarchingNeighborhood neighs;
+  typename _TInputImage::SpacingType spac = this->GetInput( )->GetSpacing( );
+  for( unsigned int d = 0; d < _TInputImage::ImageDimension; ++d )
+  {
+    for( int i = -1; i <= 1; i += 2 )
+    {
+      TVertex n = v;
+      n[ d ] += i;
+      neighs.push_back( TFastMarchingNeighbor( n, spac[ d ] ) );
+
+    } // rof
+
+  } // rof
+  return( neighs );
+}
+
+#endif // __fpa__Image__FastMarching__hxx__
+
+// eof - $RCSfile$
index 78c42a77d938003a49ad297d325771713f5e87ac..70ac8d0027e8bca7c218a5c1cc11aeb493255590 100644 (file)
@@ -14,16 +14,17 @@ namespace fpa
       {
         /**
          */
-        template< class _TImage >
+        template< class _TImage, class _TOutput >
         class BinaryThreshold
-          : public fpa::Image::Functors::Base< _TImage, fpa::Base::Functors::RegionGrow::Base< typename _TImage::IndexType > >
+          : public fpa::Image::Functors::Base< _TImage, fpa::Base::Functors::RegionGrow::Base< typename _TImage::IndexType, _TOutput > >
         {
         public:
           typedef _TImage                    TImage;
+          typedef _TOutput                   TOutput;
           typedef typename TImage::IndexType TIndex;
           typedef typename TImage::PixelType TPixel;
 
-          typedef fpa::Base::Functors::RegionGrow::Base< TIndex > TBase;
+          typedef fpa::Base::Functors::RegionGrow::Base< TIndex, TOutput > TBase;
           typedef fpa::Image::Functors::Base< TImage, TBase > Superclass;
           typedef BinaryThreshold                             Self;
           typedef itk::SmartPointer< Self >                   Pointer;
@@ -39,7 +40,7 @@ namespace fpa
           itkSetMacro( Upper, TPixel );
 
         public:
-          virtual bool Evaluate(
+          virtual TOutput Evaluate(
             const TIndex& a, const TIndex& b
             ) const override;
 
index 97cf465a2ab811479afd5b3bf92c337a5c6d6b99..e1853e2ca7db676bdb483d41e91f21e8497f29da 100644 (file)
@@ -4,8 +4,9 @@
 #include <limits>
 
 // -------------------------------------------------------------------------
-template< class _TImage >
-bool fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage >::
+template< class _TImage, class _TOutput >
+_TOutput
+fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage, _TOutput >::
 Evaluate( const TIndex& a, const TIndex& b ) const
 {
   const _TImage* im =
@@ -13,15 +14,19 @@ Evaluate( const TIndex& a, const TIndex& b ) const
   if( im != NULL )
   {
     TPixel v = im->GetPixel( b );
-    return( this->m_Lower <= v && v <= this->m_Upper );
+    return(
+      ( this->m_Lower <= v && v <= this->m_Upper )?
+      this->m_InsideValue:
+      this->m_OutsideValue
+      );
   }
   else
-    return( false );
+    return( this->m_OutsideValue );
 }
 
 // -------------------------------------------------------------------------
-template< class _TImage >
-fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage >::
+template< class _TImage, class _TOutput >
+fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage, _TOutput >::
 BinaryThreshold( )
   : Superclass( )
 {
@@ -33,8 +38,8 @@ BinaryThreshold( )
 }
 
 // -------------------------------------------------------------------------
-template< class _TImage >
-fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage >::
+template< class _TImage, class _TOutput >
+fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage, _TOutput >::
 ~BinaryThreshold( )
 {
 }
index 9f777b01f19326584a64de06f81bb32aa0028f2c..0e4ebf7d484d14570c14ec3d93dcac43449fec6a 100644 (file)
@@ -4,6 +4,7 @@
 #include <vector>
 #include <fpa/Image/Functors/Base.h>
 #include <itkFunctionBase.h>
+#include <itkImageBase.h>
 
 namespace fpa
 {
@@ -13,12 +14,12 @@ namespace fpa
     {
       /**
        */
-      template< class _TImage >
+      template< unsigned int _VDim >
       class SimpleNeighborhood
-        : public fpa::Image::Functors::Base< _TImage, itk::FunctionBase< typename _TImage::IndexType, std::vector< typename _TImage::IndexType > > >
+        : public fpa::Image::Functors::Base< itk::ImageBase< _VDim >, itk::FunctionBase< itk::Index< _VDim >, std::vector< itk::Index< _VDim > > > >
       {
       public:
-        typedef _TImage                         TImage;
+        typedef itk::ImageBase< _VDim >         TImage;
         typedef typename TImage::IndexType      TIndex;
         typedef typename TIndex::OffsetType     TOffset;
         typedef std::vector< TIndex >           TOutput;
index a09dab8a130f9cc1c1b2fd9dbf8cde142f368bd7..172425d8c165f6ee0d63a038c40e9406bcbc516b 100644 (file)
@@ -2,9 +2,9 @@
 #define __fpa__Image__Functors__SimpleNeighborhood__hxx__
 
 // -------------------------------------------------------------------------
-template< class _TImage >
-typename fpa::Image::Functors::SimpleNeighborhood< _TImage >::
-TOutput fpa::Image::Functors::SimpleNeighborhood< _TImage >::
+template< unsigned int _VDim >
+typename fpa::Image::Functors::SimpleNeighborhood< _VDim >::
+TOutput fpa::Image::Functors::SimpleNeighborhood< _VDim >::
 Evaluate( const TIndex& center ) const
 {
   if( this->m_Offsets.size( ) == 0 )
@@ -17,7 +17,7 @@ Evaluate( const TIndex& center ) const
   } // fi
 
   TOutput res;
-  typename _TImage::RegionType reg = this->m_Image->GetRequestedRegion( );
+  typename TImage::RegionType reg = this->m_Image->GetRequestedRegion( );
   for( int i = 0; i < this->m_Offsets.size( ); ++i )
   {
     TIndex idx = center + this->m_Offsets[ i ];
@@ -29,8 +29,8 @@ Evaluate( const TIndex& center ) const
 }
 
 // -------------------------------------------------------------------------
-template< class _TImage >
-fpa::Image::Functors::SimpleNeighborhood< _TImage >::
+template< unsigned int _VDim >
+fpa::Image::Functors::SimpleNeighborhood< _VDim >::
 SimpleNeighborhood( )
   : Superclass( ),
     m_Order( 1 )
@@ -38,18 +38,18 @@ SimpleNeighborhood( )
 }
 
 // -------------------------------------------------------------------------
-template< class _TImage >
- fpa::Image::Functors::SimpleNeighborhood< _TImage >::
+template< unsigned int _VDim >
+ fpa::Image::Functors::SimpleNeighborhood< _VDim >::
 ~SimpleNeighborhood( )
 {
 }
 
 // -------------------------------------------------------------------------
-template< class _TImage >
-void fpa::Image::Functors::SimpleNeighborhood< _TImage >::
+template< unsigned int _VDim >
+void fpa::Image::Functors::SimpleNeighborhood< _VDim >::
 _1stCombination( ) const
 {
-  for( int d = 0; d < _TImage::ImageDimension; ++d )
+  for( int d = 0; d < TImage::ImageDimension; ++d )
   {
     typename TIndex::OffsetType off;
     off.Fill( 0 );
@@ -64,8 +64,8 @@ _1stCombination( ) const
 }
 
 // -------------------------------------------------------------------------
-template< class _TImage >
-void fpa::Image::Functors::SimpleNeighborhood< _TImage >::
+template< unsigned int _VDim >
+void fpa::Image::Functors::SimpleNeighborhood< _VDim >::
 _2ndCombination( ) const
 {
   std::vector< std::vector< std::vector< int > > > M;
@@ -75,7 +75,7 @@ _2ndCombination( ) const
   base.push_back( -1 );
   base.push_back(  0 );
   base.push_back(  1 );
-  int dim = _TImage::ImageDimension;
+  int dim = TImage::ImageDimension;
 
   M.push_back( std::vector< std::vector< int > >( ) );
   for( int j = 0; j < base.size( ); ++j )
similarity index 64%
rename from lib/fpa/Image/Functors/SimpleDijkstraCost.h
rename to lib/fpa/Image/Functors/VertexCost.h
index bad95001c3a80f4e1b62395d1508ca24b6cb888a..a6f3e451beaee1d95b7a02cf9e607f55e5a35d30 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __fpa__Image__Functors__SimpleDijkstraCost__h__
-#define __fpa__Image__Functors__SimpleDijkstraCost__h__
+#ifndef __fpa__Image__Functors__VertexCost__h__
+#define __fpa__Image__Functors__VertexCost__h__
 
 #include <fpa/Image/Functors/Base.h>
-#include <fpa/Base/DijkstraCostFunctionBase.h>
+#include <fpa/Base/Functors/VertexCostFunctionBase.h>
 
 namespace fpa
 {
@@ -13,23 +13,23 @@ namespace fpa
       /**
        */
       template< class _TImage, class _TOutput >
-      class SimpleDijkstraCost
-        : public fpa::Image::Functors::Base< _TImage, fpa::Base::DijkstraCostFunctionBase< typename _TImage::IndexType, _TOutput > >
+      class VertexCost
+        : public fpa::Image::Functors::Base< _TImage, fpa::Base::Functors::VertexCostFunctionBase< typename _TImage::IndexType, _TOutput > >
       {
       public:
         typedef _TImage                    TImage;
         typedef typename TImage::IndexType TIndex;
         typedef _TOutput                   TOutput;
 
-        typedef fpa::Base::DijkstraCostFunctionBase< TIndex, TOutput > TBaseFunctor;
+        typedef fpa::Base::Functors::VertexCostFunctionBase< TIndex, TOutput > TBaseFunctor;
         typedef fpa::Image::Functors::Base< TImage, TBaseFunctor > Superclass;
-        typedef SimpleDijkstraCost              Self;
+        typedef VertexCost              Self;
         typedef itk::SmartPointer< Self >       Pointer;
         typedef itk::SmartPointer< const Self > ConstPointer;
 
       public:
         itkNewMacro( Self );
-        itkTypeMacro( SimpleDijkstraCost, Base );
+        itkTypeMacro( VertexCost, Base );
 
         itkBooleanMacro( UseImageSpacing );
         itkGetConstMacro( UseImageSpacing, bool );
@@ -41,12 +41,12 @@ namespace fpa
           ) const override;
 
       protected:
-        SimpleDijkstraCost( );
-        virtual ~SimpleDijkstraCost( );
+        VertexCost( );
+        virtual ~VertexCost( );
 
       private:
         // Purposely not implemented
-        SimpleDijkstraCost( const Self& other );
+        VertexCost( const Self& other );
         Self& operator=( const Self& other );
 
       protected:
@@ -60,9 +60,9 @@ namespace fpa
 } // ecapseman
 
 #ifndef ITK_MANUAL_INSTANTIATION
-#  include <fpa/Image/Functors/SimpleDijkstraCost.hxx>
+#  include <fpa/Image/Functors/VertexCost.hxx>
 #endif // ITK_MANUAL_INSTANTIATION
 
-#endif // __fpa__Image__Functors__SimpleDijkstraCost__h__
+#endif // __fpa__Image__Functors__VertexCost__h__
 
 // eof - $RCSfile$
similarity index 64%
rename from lib/fpa/Image/Functors/SimpleDijkstraCost.hxx
rename to lib/fpa/Image/Functors/VertexCost.hxx
index 25b8ff42aeea8498932f4b4411fe7aa6d9c5256d..3b59c52bfc39f6c6f9a7c211b203e2e6410b4b53 100644 (file)
@@ -1,10 +1,10 @@
-#ifndef __fpa__Image__Functors__SimpleDijkstraCost__hxx__
-#define __fpa__Image__Functors__SimpleDijkstraCost__hxx__
+#ifndef __fpa__Image__Functors__VertexCost__hxx__
+#define __fpa__Image__Functors__VertexCost__hxx__
 
 // -------------------------------------------------------------------------
 template< class _TImage, class _TOutput >
-typename fpa::Image::Functors::SimpleDijkstraCost< _TImage, _TOutput >::
-TOutput fpa::Image::Functors::SimpleDijkstraCost< _TImage, _TOutput >::
+typename fpa::Image::Functors::VertexCost< _TImage, _TOutput >::
+TOutput fpa::Image::Functors::VertexCost< _TImage, _TOutput >::
 Evaluate( const TIndex& a, const TIndex& b ) const
 {
   const _TImage* im =
@@ -23,8 +23,8 @@ Evaluate( const TIndex& a, const TIndex& b ) const
 
 // -------------------------------------------------------------------------
 template< class _TImage, class _TOutput >
-fpa::Image::Functors::SimpleDijkstraCost< _TImage, _TOutput >::
-SimpleDijkstraCost( )
+fpa::Image::Functors::VertexCost< _TImage, _TOutput >::
+VertexCost( )
   : Superclass( ),
     m_UseImageSpacing( false )
 {
@@ -32,11 +32,11 @@ SimpleDijkstraCost( )
 
 // -------------------------------------------------------------------------
 template< class _TImage, class _TOutput >
-fpa::Image::Functors::SimpleDijkstraCost< _TImage, _TOutput >::
-~SimpleDijkstraCost( )
+fpa::Image::Functors::VertexCost< _TImage, _TOutput >::
+~VertexCost( )
 {
 }
 
-#endif // __fpa__Image__Functors__SimpleDijkstraCost__hxx__
+#endif // __fpa__Image__Functors__VertexCost__hxx__
 
 // eof - $RCSfile$
index 3810b87ebc7899402f6be63c7e4abbfa0b4dc516..02f51b6bdb3276ac338aa27f7117dfc9f906f94c 100644 (file)
@@ -25,10 +25,8 @@ namespace fpa
       typedef typename Superclass::TOutput       TOutput;
       typedef typename Superclass::TVertex       TVertex;
       typedef typename Superclass::TGrowFunction TGrowFunction;
-      typedef
-      fpa::Image::Functors::RegionGrow::BinaryThreshold< _TInputImage >
-      TBinThresholdFunction;
-      typedef typename _TInputImage::PixelType TPixel;
+      typedef typename _TInputImage::PixelType   TPixel;
+      typedef fpa::Image::Functors::RegionGrow::BinaryThreshold< _TInputImage, TOutput > TBinThresholdFunction;
 
     protected:
       typedef typename Superclass::_TQueueNode _TQueueNode;
index 5c8b76e01a57852c5ff3ae0afcbbe33eb98b66e2..9df155ad665425a8aeee482148a962c17965b168 100644 (file)
@@ -21,12 +21,8 @@ template< class _TInputImage, class _TOutputImage >
 void fpa::Image::RegionGrow< _TInputImage, _TOutputImage >::
 _BeforeGenerateData( )
 {
-  this->m_InitResult = this->m_OutsideValue;
   this->Superclass::_BeforeGenerateData( );
-  TGrowFunction* grow =
-    dynamic_cast< TGrowFunction* >( this->GetGrowFunction( ) );
-  if( grow != NULL )
-    grow->SetImage( this->GetInput( ) );
+  this->m_InitResult = this->GetOutsideValue( );
 }
 
 #endif // __fpa__Image__RegionGrow__hxx__
index bf63d8971b463daa5071f5b30bc472629228b5b8..c60e13cd5d73d9d292f1c9fcb630ef201431cc52 100644 (file)
@@ -29,8 +29,7 @@ SkeletonFilter( )
   : Superclass( )
 {
   typedef typename _TImage::PixelType _TPixel;
-  typedef typename _TImage::Superclass _TImageBase;
-  typedef fpa::Image::Functors::SimpleNeighborhood< _TImageBase > _TNeighFunc;
+  typedef fpa::Image::Functors::SimpleNeighborhood< _TImage::ImageDimension > _TNeighFunc;
   typedef fpa::Base::Functors::Inverse< _TPixel, _TPixel > _TInvFunc;
 
   unsigned int nOutputs = this->GetNumberOfRequiredOutputs( );
@@ -48,7 +47,7 @@ SkeletonFilter( )
   this->SetNeighborhoodFunction( nfunc );
 
   typename _TInvFunc::Pointer ifunc = _TInvFunc::New( );
-  this->SetCostConversionFunction( ifunc );
+  this->SetConversionFunction( ifunc );
 }
 
 // -------------------------------------------------------------------------
diff --git a/lib/fpaInstances/BaseFilters.i b/lib/fpaInstances/BaseFilters.i
new file mode 100644 (file)
index 0000000..0cc752f
--- /dev/null
@@ -0,0 +1,12 @@
+header #define ITK_MANUAL_INSTANTIATION
+
+*define i_scalars=#scalar_types#
+*define o_scalars=#scalar_types#
+
+*tinclude fpa/Base/Algorithm:h|hxx
+*tinclude fpa/Image/Algorithm:h|hxx
+
+*instances fpa::Base::Algorithm< itk::ImageToImageFilter< itk::Image< #i_scalars#, #pdims# >, itk::Image< #o_scalars#, #pdims# > >, itk::Index< #pdims# >, #o_scalars# >
+*instances fpa::Image::Algorithm< itk::Image< #i_scalars#, #pdims# >, itk::Image< #o_scalars#, #pdims# > >
+
+** eof - $RCSfile$
index 0d455219e4be6c51beed7809ad4472eb6d529813..f7d111433dd14ce5db35fae0063a894187644604 100644 (file)
@@ -7,18 +7,32 @@ IF(USE_cpPlugins)
     ${PROJECT_BINARY_DIR}/lib
     )
   SET(_pfx fpaInstaces)
-  cpPlugins_BuildLibrary(
-    ${_pfx}DataObjects SHARED ${CMAKE_CURRENT_SOURCE_DIR}/DataObjects.i
+  SET(_instances
+    DataObjects
+    ImageFunctors
+    ImageFilters
     )
-  cpPlugins_BuildLibrary(
-    ${_pfx}Filters SHARED ${CMAKE_CURRENT_SOURCE_DIR}/Filters.i
+  SET(_build_instances)
+  FOREACH(_i ${_instances})
+    cpPlugins_BuildLibrary(
+      ${_pfx}${_i} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/${_i}.i
+      )
+    TARGET_LINK_LIBRARIES(
+      ${_pfx}${_i}
+      ${cpPlugins_AllInstances} ${ITK_LIBRARIES} ${VTK_LIBRARIES}
+      )
+    LIST(APPEND _build_instances ${_pfx}${_i})
+  ENDFOREACH(_i)
+
+  TARGET_LINK_LIBRARIES(
+    ${_pfx}ImageFilters
+    ${_pfx}DataObjects
+    ${_pfx}ImageFunctors
+    cpPlugins_ITKUnaryFunctorFilters
     )
-  TARGET_LINK_LIBRARIES(${_pfx}DataObjects ${cpPlugins_AllInstances} ${ITK_LIBRARIES} ${VTK_LIBRARIES})
-  TARGET_LINK_LIBRARIES(${_pfx}Filters ${_pfx}DataObjects)
   SET(
     fpa_AllInstances
-    ${_pfx}DataObjects
-    ${_pfx}Filters
+    ${_build_instances}
     CACHE INTERNAL "All valid instances." FORCE
     )
 ENDIF(USE_cpPlugins)
index cf7f883cacb69a3609b466081e3953c91056f358..2cc585ff3a469166828c42efe542d31bc2320b02 100644 (file)
@@ -1,16 +1,8 @@
 header #define ITK_MANUAL_INSTANTIATION
 
-tinclude fpa/Image/Functors/SimpleNeighborhood:h|hxx
-tinclude fpa/Image/Functors/SimpleDijkstraCost:h|hxx
-tinclude fpa/Image/MinimumSpanningTree:h|hxx
 tinclude fpa/Base/MinimumSpanningTree:h|hxx
+tinclude fpa/Image/MinimumSpanningTree:h|hxx
 
-cinclude set
-tinclude itkSimpleDataObjectDecorator:h|hxx
-instances itk::SimpleDataObjectDecorator< std::set< itk::Index< #pdims# >, itk::Functor::IndexLexicographicCompare< #pdims# > > >
-
-instances fpa::Image::Functors::SimpleNeighborhood< itk::ImageBase< #pdims# > >
-instances fpa::Image::Functors::SimpleDijkstraCost< itk::Image< #scalar_types#, #pdims# >, #real_types# >
 instances fpa::Base::MinimumSpanningTree< itk::Index< #pdims# >, cpExtensions::DataStructures::PolyLineParametricPath< #pdims# >, itk::Image< itk::Offset< #pdims# >, #pdims# > >
 instances fpa::Image::MinimumSpanningTree< #pdims# >
 
diff --git a/lib/fpaInstances/Filters.i b/lib/fpaInstances/Filters.i
deleted file mode 100644 (file)
index 60502a2..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-header #define ITK_MANUAL_INSTANTIATION
-
-define i_scalars=#scalar_types#
-define o_scalars=#scalar_types#
-
-tinclude fpa/Base/Algorithm:h|hxx
-tinclude fpa/Image/Algorithm:h|hxx
-
-instances fpa::Base::Algorithm< itk::ImageToImageFilter< itk::Image< #i_scalars#, #pdims# >, itk::Image< #o_scalars#, #pdims# > >, itk::Index< #pdims# >, #o_scalars# >
-instances fpa::Image::Algorithm< itk::Image< #i_scalars#, #pdims# >, itk::Image< #o_scalars#, #pdims# > >
-
-** eof - $RCSfile$
diff --git a/lib/fpaInstances/ImageFilters.i b/lib/fpaInstances/ImageFilters.i
new file mode 100644 (file)
index 0000000..e773c11
--- /dev/null
@@ -0,0 +1,28 @@
+header #define ITK_MANUAL_INSTANTIATION
+
+define all_inputs=#scalar_types#
+define all_outputs=#scalar_types#
+define all_int_types=#int_types#;#uint_types#
+
+tinclude fpa/Base/Algorithm:h|hxx
+tinclude fpa/Image/Algorithm:h|hxx
+tinclude fpa/Image/RegionGrow:h|hxx
+tinclude fpa/Base/RegionGrow:h|hxx
+tinclude fpa/Image/Dijkstra:h|hxx
+tinclude fpa/Image/FastMarching:h|hxx
+
+cinclude fpa/Base/QueueAlgorithm.hxx
+cinclude fpa/Base/PriorityQueueAlgorithm.hxx
+cinclude fpa/Base/Dijkstra.hxx
+cinclude fpa/Base/FastMarching.hxx
+
+instances fpa::Base::Algorithm< itk::ImageToImageFilter< itk::Image< #all_inputs#, #pdims# >, itk::Image< #all_outputs#, #pdims# > >, itk::Index< #pdims# >, #all_outputs# >
+instances fpa::Image::Algorithm< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
+
+instances fpa::Base::RegionGrow< fpa::Image::Algorithm< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > > >
+instances fpa::Image::RegionGrow< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
+
+instances fpa::Image::Dijkstra< itk::Image< #scalar_types#, #pdims# >, itk::Image< #real_types#, #pdims# > >
+instances fpa::Image::FastMarching< itk::Image< #scalar_types#, #pdims# >, itk::Image< #real_types#, #pdims# > >
+
+** eof - $RCSfile$
diff --git a/lib/fpaInstances/ImageFunctors.i b/lib/fpaInstances/ImageFunctors.i
new file mode 100644 (file)
index 0000000..e410091
--- /dev/null
@@ -0,0 +1,16 @@
+header #define ITK_MANUAL_INSTANTIATION
+
+define all_int_types=#int_types#;#uint_types#
+define i_scalar_types=#scalar_types#
+define o_scalar_types=#scalar_types#
+
+tinclude fpa/Image/Functors/VertexCost:h|hxx
+tinclude fpa/Image/Functors/SimpleNeighborhood:h|hxx
+tinclude fpa/Image/Functors/RegionGrow/BinaryThreshold:h|hxx
+cinclude itkImage.h
+
+instances fpa::Image::Functors::VertexCost< itk::Image< #i_scalar_types#, #pdims# >, #o_scalar_types# >
+instances fpa::Image::Functors::SimpleNeighborhood< #pdims# >
+instances fpa::Image::Functors::RegionGrow::BinaryThreshold< itk::Image< #scalar_types#, #pdims# >, #all_int_types# >
+
+** eof - $RCSfile$
index 73054623147048f64a1597d4290246e6f40bf789..383c5d67565609c0c9f6c5a2a4019aad4c31adef 100644 (file)
@@ -13,31 +13,43 @@ IF(USE_cpPlugins)
   SET(
     _dirs
     ImageAlgorithms
-    RegionGrowFunctors
-    DijkstraFunctors
+    RegionGrowFunctors
+    DijkstraFunctors
     )
-  OPTION(BUILD_ExperimentationPlugins "Build plugins for experimentation?" OFF)
-  IF(BUILD_ExperimentationPlugins)
-    LIST(APPEND _dirs Experiments)
-  ENDIF(BUILD_ExperimentationPlugins)
 
   FOREACH(_d ${_dirs})
     cpPlugins_BuildPluginsLibrary(
-      fpaPlugins${_d} ${CMAKE_CURRENT_SOURCE_DIR}/${_d}
+      fpaPlugins_${_d} ${CMAKE_CURRENT_SOURCE_DIR}/${_d}
       )
     TARGET_LINK_LIBRARIES(
-      fpaPlugins${_d}
+      fpaPlugins_${_d}
       cpPlugins cpPluginsDataObjects cpExtensions
       ${fpa_AllInstances}
       )
   ENDFOREACH(_d)
-  TARGET_LINK_LIBRARIES(
-    fpaPluginsImageAlgorithms
-    cpPlugins_ITKUnaryFunctorFilters
-    fpaPluginsRegionGrowFunctors
-    fpaPluginsDijkstraFunctors
-    )
 
+
+#  OPTION(BUILD_ExperimentationPlugins "Build plugins for experimentation?" OFF)
+#  IF(BUILD_ExperimentationPlugins)
+#    LIST(APPEND _dirs Experiments)
+#  ENDIF(BUILD_ExperimentationPlugins)
+
+#  FOREACH(_d ${_dirs})
+#    cpPlugins_BuildPluginsLibrary(
+#      fpaPlugins${_d} ${CMAKE_CURRENT_SOURCE_DIR}/${_d}
+#      )
+#    TARGET_LINK_LIBRARIES(
+#      fpaPlugins${_d}
+#      cpPlugins cpPluginsDataObjects cpExtensions
+#      ${fpa_AllInstances}
+#      )
+#  ENDFOREACH(_d)
+#  TARGET_LINK_LIBRARIES(
+#    fpaPluginsImageAlgorithms
+#    cpPlugins_ITKUnaryFunctorFilters
+#    fpaPluginsRegionGrowFunctors
+#    fpaPluginsDijkstraFunctors
+#    )
 ENDIF(USE_cpPlugins)
 
 ## eof - $RCSfile$
index e19327a9d88951361cefd527c3c345fb0cb9a73d..a053e86b22699175f0c308cfc86414a5f5066b02 100644 (file)
@@ -2,7 +2,8 @@
 #include <cpInstances/DataObjects/Image.h>
 
 #include <itkImage.h>
-#include <fpa/Image/Functors/SimpleDijkstraCost.h>
+
+// TODO: #include <fpa/Image/Functors/SimpleDijkstraCost.h>
 
 // -------------------------------------------------------------------------
 fpaPluginsDijkstraFunctors::SimpleImageDijkstraCost::
@@ -53,19 +54,21 @@ template< class _TImage, class _TOutput >
 void fpaPluginsDijkstraFunctors::SimpleImageDijkstraCost::
 _GD1( _TImage* image )
 {
-  typedef
-    fpa::Image::Functors::SimpleDijkstraCost< _TImage, _TOutput >
-    _TFunctor;
-  auto out = this->GetOutput( "Output" );
-  auto f = out->GetITK< _TFunctor >( );
-  if( f == NULL )
-  {
-    typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
-    f = ptr_f.GetPointer( );
-    out->SetITK( f );
+  /* TODO
+     typedef
+     fpa::Image::Functors::SimpleDijkstraCost< _TImage, _TOutput >
+     _TFunctor;
+     auto out = this->GetOutput( "Output" );
+     auto f = out->GetITK< _TFunctor >( );
+     if( f == NULL )
+     {
+     typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
+     f = ptr_f.GetPointer( );
+     out->SetITK( f );
 
-  } // fi
-  f->SetUseImageSpacing( this->m_Parameters.GetBool( "UseImageSpacing" ) );
+     } // fi
+     f->SetUseImageSpacing( this->m_Parameters.GetBool( "UseImageSpacing" ) );
+  */
 }
 
 // eof - $RCSfile$
index ae7c6c3c84db4805fa50b29bacd5deb4850dfec2..3772488dbf21fc4cc968ccaa483b136e49302f75 100644 (file)
@@ -11,7 +11,6 @@ BaseFilter( )
 
   this->_ConfigureInput< _TImage >( "Input", true, false );
   this->_ConfigureInput< _TData >( "Seeds", true, false );
-  this->_ConfigureInput< _TData >( "Neighborhood", false, false );
   this->_ConfigureOutput< _TImage >( "Output" );
 
   this->m_Parameters.ConfigureAsUint( "NeighborhoodOrder", 1 );
index 256888161cb38796656e05276548e2537a7ea411..0b871a5f4cf06a1f0c6db17ea65446a4457791a3 100644 (file)
@@ -2,8 +2,11 @@
 #define __fpaPluginsImageAlgorithms__BaseFilter__h__
 
 #include <fpaPluginsImageAlgorithms_Export.h>
-#include <cpPlugins/Pipeline/ProcessObject.h>
+
 #include <vtkPolyData.h>
+#include <cpPlugins/Pipeline/ProcessObject.h>
+
+#define ITK_MANUAL_INSTANTIATION
 #include <fpa/Image/Functors/SimpleNeighborhood.h>
 
 namespace fpaPluginsImageAlgorithms
@@ -14,10 +17,10 @@ namespace fpaPluginsImageAlgorithms
     : public cpPlugins::Pipeline::ProcessObject
   {
   public:
-    typedef BaseFilter                            Self;
+    typedef BaseFilter                         Self;
     typedef cpPlugins::Pipeline::ProcessObject Superclass;
-    typedef itk::SmartPointer< Self >             Pointer;
-    typedef itk::SmartPointer< const Self >       ConstPointer;
+    typedef itk::SmartPointer< Self >          Pointer;
+    typedef itk::SmartPointer< const Self >    ConstPointer;
 
   public:
     itkTypeMacro( BaseFilter, cpPlugins::Pipeline::ProcessObject );
@@ -28,19 +31,10 @@ namespace fpaPluginsImageAlgorithms
     virtual ~BaseFilter( );
 
     template< class _TFilter, class _TImage >
-    inline void _ConfigureFilter( _TFilter* filter, _TImage* image );
-
-    /* TODO
-
-       template< class _TFilter >
-       inline void _ExecuteFilter( _TFilter* filter );
-
-       template< class _TFilter >
-       inline void _ConfigureDebugger( _TFilter* filter );
-
-       template< class _TFilter >
-       inline void _DeconfigureDebugger( _TFilter* filter );
-    */
+    inline void _ConfigureFilter(
+      _TFilter* filter, _TImage* image,
+      std::vector< typename _TImage::IndexType >& seeds
+      );
 
   private:
     // Purposely not implemented.
@@ -53,11 +47,14 @@ namespace fpaPluginsImageAlgorithms
 // -------------------------------------------------------------------------
 template< class _TFilter, class _TImage >
 void fpaPluginsImageAlgorithms::BaseFilter::
-_ConfigureFilter( _TFilter* filter, _TImage* image )
+_ConfigureFilter(
+  _TFilter* filter, _TImage* image,
+  std::vector< typename _TImage::IndexType >& seeds
+  )
 {
   typedef typename _TFilter::TNeighborhoodFunction _TNeighborhood;
   typedef
-    fpa::Image::Functors::SimpleNeighborhood< typename _TImage::Superclass >
+    fpa::Image::Functors::SimpleNeighborhood< _TImage::ImageDimension >
     _TSimpleNeigh;
 
   // Simple configuration
@@ -65,35 +62,30 @@ _ConfigureFilter( _TFilter* filter, _TImage* image )
   filter->SetStopAtOneFront( this->m_Parameters.GetBool( "StopAtOneFront" ) );
 
   // Neighborhood function
-  auto neig = this->GetInputData< _TNeighborhood >( "Neighborhood" );
-  if( neig == NULL )
-  {
-    typename _TSimpleNeigh::Pointer sfunc = _TSimpleNeigh::New( );
-    sfunc->SetOrder( this->m_Parameters.GetUint( "NeighborhoodOrder" ) );
-    filter->SetNeighborhoodFunction( sfunc );
-  }
-  else
-    filter->SetNeighborhoodFunction( neig );
+  typename _TSimpleNeigh::Pointer sfunc = _TSimpleNeigh::New( );
+  sfunc->SetOrder( this->m_Parameters.GetUint( "NeighborhoodOrder" ) );
+  filter->SetNeighborhoodFunction( sfunc );
 
   // Assign seeds
-  auto seeds = this->GetInputData< vtkPolyData >( "Seeds" );
-  if( seeds != NULL )
+  seeds.clear( );
+  auto pnt_seeds = this->GetInputData< vtkPolyData >( "Seeds" );
+  if( pnt_seeds != NULL )
   {
     typename _TImage::PointType pnt;
     typename _TImage::IndexType idx;
     unsigned int dim =
       ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3;
 
-    for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i )
+    for( int i = 0; i < pnt_seeds->GetNumberOfPoints( ); ++i )
     {
       double buf[ 3 ];
-      seeds->GetPoint( i, buf );
+      pnt_seeds->GetPoint( i, buf );
       pnt.Fill( 0 );
       for( unsigned int d = 0; d < dim; ++d )
         pnt[ d ] = buf[ d ];
 
       if( image->TransformPhysicalPointToIndex( pnt, idx ) )
-        filter->AddSeed( idx, 0 );
+        seeds.push_back( idx );
 
     } // rof
 
index 45f01186721332dc957a6f1079cf326bd610a48f..c15d96fb4506b1a3bb3d2c6f868c6388d620954d 100644 (file)
@@ -11,8 +11,8 @@ Dijkstra( )
   typedef cpPlugins::Pipeline::DataObject _TData;
   typedef cpInstances::DataObjects::Image _TMST;
 
-  this->_ConfigureInput< _TData >( "Cost", false, false );
-  this->_ConfigureInput< _TData >( "CostConversion", false, false );
+  this->_ConfigureInput< _TData >( "VertexFunction", false, false );
+  this->_ConfigureInput< _TData >( "ConversionFunction", false, false );
   this->_ConfigureOutput< _TMST >( "MST" );
 
   std::vector< std::string > choices;
@@ -56,20 +56,31 @@ void fpaPluginsImageAlgorithms::Dijkstra::
 _GD1( _TInputImage* image )
 {
   typedef fpa::Image::Dijkstra< _TInputImage, _TOutputImage > _TFilter;
-  typedef typename _TFilter::TCostConversionFunction _TCostConversion;
-  typedef typename _TFilter::TCostFunction           _TCost;
+  typedef typename _TFilter::TConversionFunction  _TConversionFunction;
+  typedef typename _TFilter::TVertexFunction          _TVertexFunction;
 
   auto filter = this->_CreateITK< _TFilter >( );
-  this->_ConfigureFilter( filter, image );
-  auto cost = this->GetInputData< _TCost >( "Cost" );
-  auto conv = this->GetInputData< _TCostConversion >( "CostConversion" );
-  if( cost != NULL )
-    filter->SetCostFunction( cost );
-  if( conv != NULL )
-    filter->SetCostConversionFunction( conv );
+  std::vector< typename _TInputImage::IndexType > seeds;
+  this->_ConfigureFilter( filter, image, seeds );
+  filter->ClearSeeds( );
+  for( auto seed : seeds )
+    filter->AddSeed( seed, ( typename _TOutputImage::PixelType )( 0 ) );
   filter->Update( );
   this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
-  this->GetOutput( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) );
+
+  /* TODO
+     auto filter = this->_CreateITK< _TFilter >( );
+     this->_ConfigureFilter( filter, image );
+     auto cost = this->GetInputData< _TCost >( "Cost" );
+     auto conv = this->GetInputData< _TCostConversion >( "CostConversion" );
+     if( cost != NULL )
+     filter->SetCostFunction( cost );
+     if( conv != NULL )
+     filter->SetCostConversionFunction( conv );
+     filter->Update( );
+     this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+     this->GetOutput( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) );
+  */
 }
 
 // eof - $RCSfile$
diff --git a/plugins/ImageAlgorithms/FastMarching.cxx b/plugins/ImageAlgorithms/FastMarching.cxx
new file mode 100644 (file)
index 0000000..5805e30
--- /dev/null
@@ -0,0 +1,86 @@
+#include <ImageAlgorithms/FastMarching.h>
+#include <cpInstances/DataObjects/Image.h>
+
+#include <fpa/Image/FastMarching.h>
+
+// -------------------------------------------------------------------------
+fpaPluginsImageAlgorithms::FastMarching::
+FastMarching( )
+  : Superclass( )
+{
+  typedef cpPlugins::Pipeline::DataObject _TData;
+  typedef cpInstances::DataObjects::Image _TMST;
+
+  this->_ConfigureInput< _TData >( "VertexFunction", false, false );
+  this->_ConfigureInput< _TData >( "ConversionFunction", false, false );
+  this->_ConfigureOutput< _TMST >( "MST" );
+
+  std::vector< std::string > choices;
+  choices.push_back( "float" );
+  choices.push_back( "double" );
+  this->m_Parameters.ConfigureAsChoices( "ResultType", choices );
+  this->m_Parameters.SetSelectedChoice( "ResultType", "float" );
+}
+
+// -------------------------------------------------------------------------
+fpaPluginsImageAlgorithms::FastMarching::
+~FastMarching( )
+{
+}
+
+// -------------------------------------------------------------------------
+void fpaPluginsImageAlgorithms::FastMarching::
+_GenerateData( )
+{
+  auto o = this->GetInputData( "Input" );
+  cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
+    this->_Error( "Invalid input image." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void fpaPluginsImageAlgorithms::FastMarching::
+_GD0( _TImage* image )
+{
+  typedef itk::Image< float, _TImage::ImageDimension >  _TFloat;
+  typedef itk::Image< double, _TImage::ImageDimension > _TDouble;
+
+  auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
+  if     ( rtype == "float"  ) this->_GD1< _TImage, _TFloat >( image );
+  else if( rtype == "double" ) this->_GD1< _TImage, _TDouble >( image );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+void fpaPluginsImageAlgorithms::FastMarching::
+_GD1( _TInputImage* image )
+{
+  typedef fpa::Image::FastMarching< _TInputImage, _TOutputImage > _TFilter;
+  typedef typename _TFilter::TConversionFunction      _TConversionFunction;
+  typedef typename _TFilter::TVertexFunction              _TVertexFunction;
+
+  auto filter = this->_CreateITK< _TFilter >( );
+  std::vector< typename _TInputImage::IndexType > seeds;
+  this->_ConfigureFilter( filter, image, seeds );
+  filter->ClearSeeds( );
+  for( auto seed : seeds )
+    filter->AddSeed( seed, ( typename _TOutputImage::PixelType )( 0 ) );
+  filter->Update( );
+  this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+
+  /* TODO
+     auto filter = this->_CreateITK< _TFilter >( );
+     this->_ConfigureFilter( filter, image );
+     auto cost = this->GetInputData< _TCost >( "Cost" );
+     auto conv = this->GetInputData< _TCostConversion >( "CostConversion" );
+     if( cost != NULL )
+     filter->SetCostFunction( cost );
+     if( conv != NULL )
+     filter->SetCostConversionFunction( conv );
+     filter->Update( );
+     this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+     this->GetOutput( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) );
+  */
+}
+
+// eof - $RCSfile$
diff --git a/plugins/ImageAlgorithms/FastMarching.h b/plugins/ImageAlgorithms/FastMarching.h
new file mode 100644 (file)
index 0000000..3238975
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef __fpaPluginsImageAlgorithms__FastMarching__h__
+#define __fpaPluginsImageAlgorithms__FastMarching__h__
+
+#include <ImageAlgorithms/BaseFilter.h>
+
+namespace fpaPluginsImageAlgorithms
+{
+  /**
+   */
+  class fpaPluginsImageAlgorithms_EXPORT FastMarching
+    : public BaseFilter
+  {
+    cpPluginsObject( FastMarching, BaseFilter, fpaImageAlgorithms );
+
+  protected:
+    template< class _TImage >
+    inline void _GD0( _TImage* image );
+
+    template< class _TInputImage, class _TOutputPixel >
+    inline void _GD1( _TInputImage* image );
+  };
+
+} // ecapseman
+
+#endif // __fpaPluginsImageAlgorithms__FastMarching__h__
+
+// eof - $RCSfile$
index 0dcdcecb966f6f003c80815babe0be6dc5dbdb4f..a805d13fe35953b5bf916c20fd234aa24f95cda9 100644 (file)
@@ -1,23 +1,23 @@
 header #define ITK_MANUAL_INSTANTIATION
 
-tinclude fpa/Image/Functors/SimpleNeighborhood:h|hxx
-instances fpa::Image::Functors::SimpleNeighborhood< itk::Image< #scalar_types#, #pdims# > >
-
-cinclude fpa/Base/RegionGrow.hxx
-define all_int_types=#int_types#;#uint_types#
-tinclude fpa/Image/RegionGrow:h|hxx
-tinclude fpa/Image/MoriRegionGrowHelper:h|hxx
-tinclude fpa/Image/MoriRegionGrow:h|hxx
-instances fpa::Image::RegionGrow< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
-instances fpa::Image::MoriRegionGrowHelper< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
-instances fpa::Image::MoriRegionGrow< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
-
-cinclude fpa/Base/Dijkstra.hxx
-tinclude fpa/Image/Dijkstra:h|hxx
-instances fpa::Image::Dijkstra< itk::Image< #scalar_types#, #pdims# >, itk::Image< #real_types#, #pdims# > >
-
-tinclude fpa/Image/SkeletonFilter:h|hxx
-instances fpa::Image::SkeletonFilter< itk::Image< #real_types#, #pdims# > >
+*tinclude fpa/Image/Functors/SimpleNeighborhood:h|hxx
+*instances fpa::Image::Functors::SimpleNeighborhood< itk::Image< #scalar_types#, #pdims# > >
+
+*cinclude fpa/Base/RegionGrow.hxx
+*define all_int_types=#int_types#;#uint_types#
+*tinclude fpa/Image/RegionGrow:h|hxx
+*tinclude fpa/Image/MoriRegionGrowHelper:h|hxx
+*tinclude fpa/Image/MoriRegionGrow:h|hxx
+*instances fpa::Image::RegionGrow< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
+*instances fpa::Image::MoriRegionGrowHelper< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
+*instances fpa::Image::MoriRegionGrow< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
+
+*cinclude fpa/Base/Dijkstra.hxx
+*tinclude fpa/Image/Dijkstra:h|hxx
+*instances fpa::Image::Dijkstra< itk::Image< #scalar_types#, #pdims# >, itk::Image< #real_types#, #pdims# > >
+
+*tinclude fpa/Image/SkeletonFilter:h|hxx
+*instances fpa::Image::SkeletonFilter< itk::Image< #real_types#, #pdims# > >
 
 
 
index f8e323c1509b5b437d479af86af7559975f4ef9c..cda89792a19c53d3baaff57471b4cdc441ab557a 100644 (file)
@@ -61,47 +61,49 @@ template< class _TInputImage, class _TOutputPixel >
 void fpaPluginsImageAlgorithms::MoriRegionGrow::
 _GD1( _TInputImage* image )
 {
-  typedef
-    itk::Image< _TOutputPixel, _TInputImage::ImageDimension >
-    _TOutputImage;
-  typedef fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage > _TFilter;
+  /* TODO
+     typedef
+     itk::Image< _TOutputPixel, _TInputImage::ImageDimension >
+     _TOutputImage;
+     typedef fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage > _TFilter;
 
-  auto filter = this->_CreateITK< _TFilter >( );
-  filter->SetInput( image );
-  filter->SetInsideValue( this->m_Parameters.GetInt( "InsideValue" ) );
-  filter->SetOutsideValue( this->m_Parameters.GetInt( "OutsideValue" ) );
-  filter->SetStep( this->m_Parameters.GetReal( "Step" ) );
-  filter->SetLower( this->m_Parameters.GetReal( "Lower" ) );
-  filter->SetUpper( this->m_Parameters.GetReal( "Upper" ) );
+     auto filter = this->_CreateITK< _TFilter >( );
+     filter->SetInput( image );
+     filter->SetInsideValue( this->m_Parameters.GetInt( "InsideValue" ) );
+     filter->SetOutsideValue( this->m_Parameters.GetInt( "OutsideValue" ) );
+     filter->SetStep( this->m_Parameters.GetReal( "Step" ) );
+     filter->SetLower( this->m_Parameters.GetReal( "Lower" ) );
+     filter->SetUpper( this->m_Parameters.GetReal( "Upper" ) );
 
-  // Assign seed
-  auto seeds = this->GetInputData< vtkPolyData >( "Seed" );
-  if( seeds != NULL )
-  {
-    typename _TInputImage::PointType pnt;
-    typename _TInputImage::IndexType idx;
-    unsigned int dim =
-      ( _TInputImage::ImageDimension < 3 )? _TInputImage::ImageDimension: 3;
-    if( seeds->GetNumberOfPoints( ) > 0 )
-    {
-      double buf[ 3 ];
-      seeds->GetPoint( 0, buf );
-      pnt.Fill( 0 );
-      for( unsigned int d = 0; d < dim; ++d )
-        pnt[ d ] = buf[ d ];
+     // Assign seed
+     auto seeds = this->GetInputData< vtkPolyData >( "Seed" );
+     if( seeds != NULL )
+     {
+     typename _TInputImage::PointType pnt;
+     typename _TInputImage::IndexType idx;
+     unsigned int dim =
+     ( _TInputImage::ImageDimension < 3 )? _TInputImage::ImageDimension: 3;
+     if( seeds->GetNumberOfPoints( ) > 0 )
+     {
+     double buf[ 3 ];
+     seeds->GetPoint( 0, buf );
+     pnt.Fill( 0 );
+     for( unsigned int d = 0; d < dim; ++d )
+     pnt[ d ] = buf[ d ];
 
-      if( image->TransformPhysicalPointToIndex( pnt, idx ) )
-        filter->SetSeed( idx );
-    }
-    else
-      this->_Error( "No given seeds." );
-  }
-  else
-    this->_Error( "No given seeds." );
+     if( image->TransformPhysicalPointToIndex( pnt, idx ) )
+     filter->SetSeed( idx );
+     }
+     else
+     this->_Error( "No given seeds." );
+     }
+     else
+     this->_Error( "No given seeds." );
 
-  filter->Update( );
-  this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
-  this->GetOutput( "AuxiliaryOutput" )->SetITK( filter->GetAuxiliaryImage( ) );
+     filter->Update( );
+     this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+     this->GetOutput( "AuxiliaryOutput" )->SetITK( filter->GetAuxiliaryImage( ) );
+  */
 }
 
 // eof - $RCSfile$
index bec55ee530f1c332248ff7d8834bcffca51ac53d..e1aff3e3effc67bfea2eef7da2dd1e8fee73b2b3 100644 (file)
@@ -59,11 +59,18 @@ _GD1( _TInputImage* image )
   typedef fpa::Image::RegionGrow< _TInputImage, _TOutputImage > _TFilter;
   typedef typename _TFilter::TGrowFunction                      _TGrow;
 
+  _TOutputPixel i_val = _TOutputPixel( this->m_Parameters.GetInt( "InsideValue" ) );
+  _TOutputPixel o_val = _TOutputPixel( this->m_Parameters.GetInt( "OutsideValue" ) );
+
   auto filter = this->_CreateITK< _TFilter >( );
-  this->_ConfigureFilter( filter, image );
+  std::vector< typename _TInputImage::IndexType > seeds;
+  this->_ConfigureFilter( filter, image, seeds );
+  filter->ClearSeeds( );
+  for( auto seed : seeds )
+    filter->AddSeed( seed, i_val );
   filter->SetGrowFunction( this->GetInputData< _TGrow >( "GrowFunction" ) );
-  filter->SetInsideValue( this->m_Parameters.GetInt( "InsideValue" ) );
-  filter->SetOutsideValue( this->m_Parameters.GetInt( "OutsideValue" ) );
+  filter->SetInsideValue( i_val );
+  filter->SetOutsideValue( o_val );
   filter->Update( );
   this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
 }
index 8d434c75311e23b7858d8540164824c06e12f63d..03689aa5e023bf9e66ea97912bb9ee1c31cb9ccd 100644 (file)
@@ -2,9 +2,12 @@
 #include <cpInstances/DataObjects/Image.h>
 #include <cpInstances/DataObjects/Skeleton.h>
 
-#include <fpa/Image/SkeletonFilter.h>
 #include <itkImage.h>
-#include <vtkPolyData.h>
+
+/* TODO
+   #include <fpa/Image/SkeletonFilter.h>
+   #include <vtkPolyData.h>
+*/
 
 // -------------------------------------------------------------------------
 fpaPluginsImageAlgorithms::SkeletonFilter::
@@ -41,36 +44,38 @@ template< class _TImage >
 void fpaPluginsImageAlgorithms::SkeletonFilter::
 _GD0( _TImage* image )
 {
-  typedef fpa::Image::SkeletonFilter< _TImage > _TFilter;
-  auto filter = this->_CreateITK< _TFilter >( );
-  filter->SetInput( image );
+  /* TODO
+     typedef fpa::Image::SkeletonFilter< _TImage > _TFilter;
+     auto filter = this->_CreateITK< _TFilter >( );
+     filter->SetInput( image );
 
-  auto seeds = this->GetInputData< vtkPolyData >( "Seeds" );
-  if( seeds != NULL )
-  {
-    typename _TImage::PointType pnt;
-    typename _TImage::IndexType idx;
-    unsigned int dim =
-      ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3;
+     auto seeds = this->GetInputData< vtkPolyData >( "Seeds" );
+     if( seeds != NULL )
+     {
+     typename _TImage::PointType pnt;
+     typename _TImage::IndexType idx;
+     unsigned int dim =
+     ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3;
 
-    for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i )
-    {
-      double buf[ 3 ];
-      seeds->GetPoint( i, buf );
-      pnt.Fill( 0 );
-      for( unsigned int d = 0; d < dim; ++d )
-        pnt[ d ] = buf[ d ];
+     for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i )
+     {
+     double buf[ 3 ];
+     seeds->GetPoint( i, buf );
+     pnt.Fill( 0 );
+     for( unsigned int d = 0; d < dim; ++d )
+     pnt[ d ] = buf[ d ];
 
-      if( image->TransformPhysicalPointToIndex( pnt, idx ) )
-        filter->AddSeed( idx, 0 );
+     if( image->TransformPhysicalPointToIndex( pnt, idx ) )
+     filter->AddSeed( idx, 0 );
 
-    } // rof
+     } // rof
 
-  } // fi
+     } // fi
 
-  filter->Update( );
-  this->GetOutput( "Skeleton" )->SetITK( filter->GetSkeleton( ) );
-  this->GetOutput( "Marks" )->SetITK( filter->GetMarks( ) );
+     filter->Update( );
+     this->GetOutput( "Skeleton" )->SetITK( filter->GetSkeleton( ) );
+     this->GetOutput( "Marks" )->SetITK( filter->GetMarks( ) );
+  */
 }
 
 // eof - $RCSfile$
index f385e4aa3d4d3a3c62d0ad75519668ed4561f0bd..3a4da319d5356fec385fcabb4857ed9fbbcdd200 100644 (file)
@@ -42,82 +42,84 @@ template< class _TImage >
 void fpaPluginsRegionGrowFunctors::BinaryThreshold::
 _GD0( _TImage* image )
 {
-  typedef itk::ConstNeighborhoodIterator< _TImage > _TInIt;
-  typedef
-    fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage >
-    _TFunctor;
-  auto out = this->GetOutput( "Output" );
-  auto f = out->GetITK< _TFunctor >( );
-  if( f == NULL )
-  {
-    typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
-    f = ptr_f.GetPointer( );
-    out->SetITK( f );
-
-  } // fi
-
-  // Compute thresholds from seeds
-  auto seeds = this->GetInputData< vtkPolyData >( "Seeds" );
-  if( seeds != NULL )
-  {
-    std::vector< typename _TImage::IndexType > indices;
-    typename _TImage::PointType pnt;
-    typename _TImage::IndexType idx;
-    unsigned int dim =
-      ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3;
-
-    for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i )
-    {
-      double buf[ 3 ];
-      seeds->GetPoint( i, buf );
-      pnt.Fill( 0 );
-      for( unsigned int d = 0; d < dim; ++d )
-        pnt[ d ] = buf[ d ];
-      if( image->TransformPhysicalPointToIndex( pnt, idx ) )
-        indices.push_back( idx );
-
-    } // rof
-
-    typename _TImage::SizeType r;
-    r.Fill( this->m_Parameters.GetUint( "Radius" ) );
-
-    _TInIt iIt( r, image, image->GetRequestedRegion( ) );
-    double v_s1 = double( 0 );
-    double v_s2 = double( 0 );
-    double v_n = double( 0 );
-    double v_min = std::numeric_limits< double >::max( );
-    double v_max = -v_min;
-    for( auto idxIt = indices.begin( ); idxIt != indices.end( ); ++idxIt )
-    {
-      iIt.SetLocation( *idxIt );
-      for( unsigned int i = 0; i < iIt.Size( ); ++i )
-      {
-        double v = double( iIt.GetPixel( i ) );
-        v_s1 += v;
-        v_s2 += v * v;
-        v_n += double( 1 );
-        v_min = ( v < v_min )? v: v_min;
-        v_max = ( v_max < v )? v: v_max;
-
-      } // rof
-
-    } // rof
-    double m = v_s1 / v_n;
-    double s = ( v_s2 - ( ( v_s1 * v_s1 ) / v_n ) ) / ( v_n - double( 1 ) );
-    s = std::sqrt( s );
-    v_min = m - s;
-    v_max = m + s;
-    f->SetLower( v_min );
-    f->SetUpper( v_max );
-    this->m_Parameters.SetReal( "Lower", f->GetLower( ) );
-    this->m_Parameters.SetReal( "Upper", f->GetUpper( ) );
-  }
-  else
-  {
-    f->SetLower( this->m_Parameters.GetReal( "Lower" ) );
-    f->SetUpper( this->m_Parameters.GetReal( "Upper" ) );
-
-  } // fi
+  /* TODO
+     typedef itk::ConstNeighborhoodIterator< _TImage > _TInIt;
+     typedef
+     fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage >
+     _TFunctor;
+     auto out = this->GetOutput( "Output" );
+     auto f = out->GetITK< _TFunctor >( );
+     if( f == NULL )
+     {
+     typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
+     f = ptr_f.GetPointer( );
+     out->SetITK( f );
+
+     } // fi
+
+     // Compute thresholds from seeds
+     auto seeds = this->GetInputData< vtkPolyData >( "Seeds" );
+     if( seeds != NULL )
+     {
+     std::vector< typename _TImage::IndexType > indices;
+     typename _TImage::PointType pnt;
+     typename _TImage::IndexType idx;
+     unsigned int dim =
+     ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3;
+
+     for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i )
+     {
+     double buf[ 3 ];
+     seeds->GetPoint( i, buf );
+     pnt.Fill( 0 );
+     for( unsigned int d = 0; d < dim; ++d )
+     pnt[ d ] = buf[ d ];
+     if( image->TransformPhysicalPointToIndex( pnt, idx ) )
+     indices.push_back( idx );
+
+     } // rof
+
+     typename _TImage::SizeType r;
+     r.Fill( this->m_Parameters.GetUint( "Radius" ) );
+
+     _TInIt iIt( r, image, image->GetRequestedRegion( ) );
+     double v_s1 = double( 0 );
+     double v_s2 = double( 0 );
+     double v_n = double( 0 );
+     double v_min = std::numeric_limits< double >::max( );
+     double v_max = -v_min;
+     for( auto idxIt = indices.begin( ); idxIt != indices.end( ); ++idxIt )
+     {
+     iIt.SetLocation( *idxIt );
+     for( unsigned int i = 0; i < iIt.Size( ); ++i )
+     {
+     double v = double( iIt.GetPixel( i ) );
+     v_s1 += v;
+     v_s2 += v * v;
+     v_n += double( 1 );
+     v_min = ( v < v_min )? v: v_min;
+     v_max = ( v_max < v )? v: v_max;
+
+     } // rof
+
+     } // rof
+     double m = v_s1 / v_n;
+     double s = ( v_s2 - ( ( v_s1 * v_s1 ) / v_n ) ) / ( v_n - double( 1 ) );
+     s = std::sqrt( s );
+     v_min = m - s;
+     v_max = m + s;
+     f->SetLower( v_min );
+     f->SetUpper( v_max );
+     this->m_Parameters.SetReal( "Lower", f->GetLower( ) );
+     this->m_Parameters.SetReal( "Upper", f->GetUpper( ) );
+     }
+     else
+     {
+     f->SetLower( this->m_Parameters.GetReal( "Lower" ) );
+     f->SetUpper( this->m_Parameters.GetReal( "Upper" ) );
+
+     } // fi
+  */
 }
 
 // eof - $RCSfile$
index e43240d35c2c6fe6e36974df22b55ad2ef2a5325..827995092f52ee125d55859281c5ef1513c2ad63 100644 (file)
@@ -2,6 +2,6 @@ header #define ITK_MANUAL_INSTANTIATION
 
 cinclude itkImage.h
 tinclude fpa/Image/Functors/RegionGrow/BinaryThreshold:h|hxx
-instances fpa::Image::Functors::RegionGrow::BinaryThreshold< itk::Image< #scalar_types#, #pdims# > >
+** instances fpa::Image::Functors::RegionGrow::BinaryThreshold< itk::Image< #scalar_types#, #pdims# > >
 
 ** eof - $RCSfile$