]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Tue, 7 Mar 2017 23:36:52 +0000 (18:36 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Tue, 7 Mar 2017 23:36:52 +0000 (18:36 -0500)
31 files changed:
lib/fpa/Base/FastMarching.hxx
lib/fpa/Base/RegionGrow.h
lib/fpa/Base/RegionGrow.hxx
lib/fpa/Image/Algorithm.hxx
lib/fpa/Image/Functors/Base.h
lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.hxx
lib/fpa/Image/RegionGrow.hxx
plugins/CMakeLists.txt
plugins/Functors/Functors.i [new file with mode: 0644]
plugins/Functors/Inverse.cxx [new file with mode: 0644]
plugins/Functors/Inverse.h [new file with mode: 0644]
plugins/ImageAlgorithms/BaseFilter.cxx
plugins/ImageAlgorithms/BaseFilter.h
plugins/ImageAlgorithms/Dijkstra.cxx
plugins/ImageAlgorithms/Dijkstra.h
plugins/ImageAlgorithms/ExtractPathFromMinimumSpanningTree.cxx [new file with mode: 0644]
plugins/ImageAlgorithms/ExtractPathFromMinimumSpanningTree.h [new file with mode: 0644]
plugins/ImageAlgorithms/FastMarching.cxx
plugins/ImageAlgorithms/FastMarching.h
plugins/ImageAlgorithms/MoriRegionGrow.cxx [deleted file]
plugins/ImageAlgorithms/MoriRegionGrow.h [deleted file]
plugins/ImageAlgorithms/RegionGrow.cxx
plugins/ImageAlgorithms/RegionGrow.h
plugins/ImageAlgorithms/SkeletonFilter.cxx [deleted file]
plugins/ImageAlgorithms/SkeletonFilter.h [deleted file]
plugins/ImageFunctors/BinaryThreshold.cxx [new file with mode: 0644]
plugins/ImageFunctors/BinaryThreshold.h [new file with mode: 0644]
plugins/ImageFunctors/Tautology.cxx [new file with mode: 0644]
plugins/ImageFunctors/Tautology.h [new file with mode: 0644]
plugins/ImageFunctors/VertexCost.cxx [new file with mode: 0644]
plugins/ImageFunctors/VertexCost.h [new file with mode: 0644]

index 61ec96845639669a190eec9106c07bc316ac31fc..0fe1cb269781e41ee0cfcfc0688d42ed97cc3089 100644 (file)
@@ -71,7 +71,8 @@ _UpdateValue( _TQueueNode& v, const _TQueueNode& p )
   }
   else
   {
-    std::cout << "-----> " << v.Vertex << " " << d << std::endl;
+    std::cout << std::endl << "-- FM --> " << v.Vertex << " " << d << std::endl;
+    std::exit( 1 );
   }
   return( true );
 }
index 6a3c9e6faebff789ed87514e7255bb5292eeaa74..4790b851a9273768e1d0ae5f4cf1e79e03d025aa 100644 (file)
@@ -48,11 +48,22 @@ namespace fpa
       virtual bool _UpdateValue(
         _TQueueNode& v, const _TQueueNode& p
         ) override;
+      virtual TOutput _GetInputValue( const _TQueueNode& v, const _TQueueNode& p ) override
+        {
+          TOutput res = this->m_InitResult;
+          if( this->m_GrowFunction.IsNotNull( ) )
+            res = this->m_GrowFunction->Evaluate( v.Vertex, p.Vertex );
+          return( res );
+        }
+
 
     private:
       // Purposely not defined
       RegionGrow( const Self& other );
       Self& operator=( const Self& other );
+
+    protected:
+      typename TGrowFunction::Pointer m_GrowFunction;
     };
 
   } // ecapseman
index 6865916c412b5771fb7270b67a2a4e14b6ea1f92..c3cb9f3a355fccca44f8f8776702fea5d2ea7013 100644 (file)
@@ -9,7 +9,8 @@ typename fpa::Base::RegionGrow< _TSuperclass >::
 TGrowFunction* fpa::Base::RegionGrow< _TSuperclass >::
 GetGrowFunction( )
 {
-  return( dynamic_cast< TGrowFunction* >( this->GetVertexFunction( ) ) );
+  // TODO: return( dynamic_cast< TGrowFunction* >( this->GetVertexFunction( ) ) );
+  return( this->m_GrowFunction );
 }
 
 // -------------------------------------------------------------------------
@@ -18,9 +19,12 @@ const typename fpa::Base::RegionGrow< _TSuperclass >::
 TGrowFunction* fpa::Base::RegionGrow< _TSuperclass >::
 GetGrowFunction( ) const
 {
-  return(
-    dynamic_cast< const TGrowFunction* >( this->GetVertexFunction( ) )
-    );
+  /* TODO
+     return(
+     dynamic_cast< const TGrowFunction* >( this->GetVertexFunction( ) )
+     );
+  */
+  return( this->m_GrowFunction );
 }
 
 // -------------------------------------------------------------------------
@@ -61,7 +65,7 @@ SetGrowFunction( TGrowFunction* f )
     f->SetOutsideValue( old_f->GetOutsideValue( ) );
 
   } // fi
-  this->SetVertexFunction( f );
+  this->m_GrowFunction = f;
 }
 
 // -------------------------------------------------------------------------
index 6e4eef139929c21ebb5fc22b182576067fde4b04..3c33e4e3ca90019e7ac77b58c1c8ae9b541948cc 100644 (file)
@@ -51,9 +51,8 @@ _BeforeGenerateData( )
     dynamic_cast< TVertexFunction* >(
       this->GetVertexFunction( )
       );
-  if( vertexFunc == NULL )
-    itkExceptionMacro( << "VertexFunction not well defined." );
-  vertexFunc->SetImage( this->GetInput( ) );
+  if( vertexFunc != NULL )
+    vertexFunc->SetImage( this->GetInput( ) );
 }
 
 // -------------------------------------------------------------------------
index 622cc0a0642f8ef23c54e19613f9ca38134d2ee2..45bd84635afa5ad8b84a5e9bfa85320724a8c794 100644 (file)
@@ -29,8 +29,8 @@ namespace fpa
       public:
         itkTypeMacro( Base, itk::FunctionBase );
 
-        itkGetConstObjectMacro( Image, TImageBase );
-        itkSetConstObjectMacro( Image, TImageBase );
+        itkGetConstObjectMacro( Image, TImage );
+        itkSetConstObjectMacro( Image, TImage );
 
       protected:
         Base( ) : Superclass( ) { }
@@ -42,7 +42,7 @@ namespace fpa
         Self& operator=( const Self& other );
 
       protected:
-        typename TImageBase::ConstPointer m_Image;
+        typename TImage::ConstPointer m_Image;
       };
 
     } // ecapseman
index e1853e2ca7db676bdb483d41e91f21e8497f29da..7f2b9dca99bc40f2e4b78cfdbe6a95d0ab3137ec 100644 (file)
@@ -15,7 +15,7 @@ Evaluate( const TIndex& a, const TIndex& b ) const
   {
     TPixel v = im->GetPixel( b );
     return(
-      ( this->m_Lower <= v && v <= this->m_Upper )?
+      ( this->m_Lower < v && v < this->m_Upper )?
       this->m_InsideValue:
       this->m_OutsideValue
       );
index 9df155ad665425a8aeee482148a962c17965b168..326dc5421ec9f3108f216f762ca1e5080c51cccc 100644 (file)
@@ -23,6 +23,10 @@ _BeforeGenerateData( )
 {
   this->Superclass::_BeforeGenerateData( );
   this->m_InitResult = this->GetOutsideValue( );
+  TGrowFunction* grow =
+    dynamic_cast< TGrowFunction* >( this->GetGrowFunction( ) );
+  if( grow != NULL )
+    grow->SetImage( this->GetInput( ) );
 }
 
 #endif // __fpa__Image__RegionGrow__hxx__
index 383c5d67565609c0c9f6c5a2a4019aad4c31adef..7a565b044810357a30ae41ecd3e0b4165cd65e1c 100644 (file)
@@ -12,6 +12,8 @@ IF(USE_cpPlugins)
 
   SET(
     _dirs
+    Functors
+    ImageFunctors
     ImageAlgorithms
     # RegionGrowFunctors
     # DijkstraFunctors
diff --git a/plugins/Functors/Functors.i b/plugins/Functors/Functors.i
new file mode 100644 (file)
index 0000000..c12aa36
--- /dev/null
@@ -0,0 +1,6 @@
+
+tinclude fpa/Base/Functors/Inverse:h|hxx
+
+instances fpa::Base::Functors::Inverse< #scalar_types#, #real_types# >
+
+** eof - $RCSfile$
diff --git a/plugins/Functors/Inverse.cxx b/plugins/Functors/Inverse.cxx
new file mode 100644 (file)
index 0000000..1786d38
--- /dev/null
@@ -0,0 +1,89 @@
+#include "Inverse.h"
+
+#include <cpInstances/DataObjects/Image.h>
+
+#include <itkImage.h>
+#include <fpa/Base/Functors/Inverse.h>
+
+// -------------------------------------------------------------------------
+void fpaPlugins_Functors::Inverse::
+Instantiate( itk::LightObject* filter )
+{
+  auto itk_filter = dynamic_cast< itk::ProcessObject* >( filter );
+  if( itk_filter != NULL )
+  {
+    auto inputs = itk_filter->GetInputs( );
+    if( inputs.size( ) > 0 )
+    {
+      cpPlugins_Demangle_Image_ScalarPixels_AllDims_2(
+        inputs[ 0 ].GetPointer( ), _GD0, itk_filter
+        )
+        this->_Error( "Invalid input data." );
+    }
+    else
+      this->_Error( "Not enough inputs." );
+  }
+  else
+    this->_Error( "Invalid instantiation filter." );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins_Functors::Inverse::
+Inverse( )
+  : Superclass( )
+{
+  this->_ConfigureOutput< cpPlugins::Pipeline::DataObject >( "Functor" );
+  this->m_Parameters.ConfigureAsReal( "NegativeValue", -1 );
+  this->GetOutput( "Functor" )->SetITK( this );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins_Functors::Inverse::
+~Inverse( )
+{
+}
+
+// -------------------------------------------------------------------------
+void fpaPlugins_Functors::Inverse::
+_GenerateData( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TInput >
+void fpaPlugins_Functors::Inverse::
+_GD0( _TInput* input, itk::ProcessObject* filter )
+{
+  auto outputs = filter->GetOutputs( );
+  if( outputs.size( ) > 0 )
+  {
+    cpPlugins_Demangle_Image_RealPixels_3(
+      outputs[ 0 ].GetPointer( ), _GD1, _TInput::ImageDimension, input, filter
+      )
+      this->_Error( "Invalid output data." );
+  }
+  else
+    this->_Error( "Not enough outputs." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInput, class _TOutput >
+void fpaPlugins_Functors::Inverse::
+_GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter )
+{
+  typedef typename _TInput::PixelType  _TIValue;
+  typedef typename _TOutput::PixelType _TOValue;
+  typedef fpa::Base::Functors::Inverse< _TIValue, _TOValue > _TFunctor;
+
+  auto f = dynamic_cast< _TFunctor* >( this->m_Functor.GetPointer( ) );
+  if( f == NULL )
+  {
+    typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
+    f = ptr_f.GetPointer( );
+    this->m_Functor = f;
+
+  } // fi
+  f->SetNegativeValue( this->m_Parameters.GetReal( "NegativeValue" ) );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/Functors/Inverse.h b/plugins/Functors/Inverse.h
new file mode 100644 (file)
index 0000000..634eeaf
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef __fpaPlugins_Functors__Inverse__h__
+#define __fpaPlugins_Functors__Inverse__h__
+
+#include <itkProcessObject.h>
+#include <fpaPlugins_Functors_Export.h>
+#include <cpPlugins/Pipeline/Functor.h>
+
+namespace fpaPlugins_Functors
+{
+  /**
+   */
+  class fpaPlugins_Functors_EXPORT Inverse
+    : public cpPlugins::Pipeline::Functor
+  {
+    cpPluginsObject( Inverse, cpPlugins::Pipeline::Functor, fpaFunctors );
+
+  public:
+    virtual void Instantiate( itk::LightObject* filter ) override;
+
+  protected:
+    template< class _TInput >
+    inline void _GD0( _TInput* input, itk::ProcessObject* filter );
+
+    template< class _TInput, class _TOutput >
+    inline void _GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter );
+  };
+
+} // ecapseman
+
+#endif // __fpaPlugins_Functors__Inverse__h__
+
+// eof - $RCSfile$
index 3772488dbf21fc4cc968ccaa483b136e49302f75..00393b43b39a217fa83f136829c0b8c8533299ba 100644 (file)
@@ -1,8 +1,8 @@
-#include <ImageAlgorithms/BaseFilter.h>
+#include "BaseFilter.h"
 #include <cpInstances/DataObjects/Image.h>
 
 // -------------------------------------------------------------------------
-fpaPluginsImageAlgorithms::BaseFilter::
+fpaPlugins_ImageAlgorithms::BaseFilter::
 BaseFilter( )
   : Superclass( )
 {
@@ -19,7 +19,7 @@ BaseFilter( )
 }
 
 // -------------------------------------------------------------------------
-fpaPluginsImageAlgorithms::BaseFilter::
+fpaPlugins_ImageAlgorithms::BaseFilter::
 ~BaseFilter( )
 {
 }
index 0b871a5f4cf06a1f0c6db17ea65446a4457791a3..b03abaae0a03ab3fb01f67f286ca04affc23a62e 100644 (file)
@@ -1,19 +1,16 @@
-#ifndef __fpaPluginsImageAlgorithms__BaseFilter__h__
-#define __fpaPluginsImageAlgorithms__BaseFilter__h__
+#ifndef __fpaPlugins_ImageAlgorithms__BaseFilter__h__
+#define __fpaPlugins_ImageAlgorithms__BaseFilter__h__
 
-#include <fpaPluginsImageAlgorithms_Export.h>
+#include <fpaPlugins_ImageAlgorithms_Export.h>
 
 #include <vtkPolyData.h>
 #include <cpPlugins/Pipeline/ProcessObject.h>
 
-#define ITK_MANUAL_INSTANTIATION
-#include <fpa/Image/Functors/SimpleNeighborhood.h>
-
-namespace fpaPluginsImageAlgorithms
+namespace fpaPlugins_ImageAlgorithms
 {
   /**
    */
-  class fpaPluginsImageAlgorithms_EXPORT BaseFilter
+  class fpaPlugins_ImageAlgorithms_EXPORT BaseFilter
     : public cpPlugins::Pipeline::ProcessObject
   {
   public:
@@ -44,9 +41,13 @@ namespace fpaPluginsImageAlgorithms
 
 } // ecapseman
 
+// -------------------------------------------------------------------------
+#define ITK_MANUAL_INSTANTIATION
+#include <fpa/Image/Functors/SimpleNeighborhood.h>
+
 // -------------------------------------------------------------------------
 template< class _TFilter, class _TImage >
-void fpaPluginsImageAlgorithms::BaseFilter::
+void fpaPlugins_ImageAlgorithms::BaseFilter::
 _ConfigureFilter(
   _TFilter* filter, _TImage* image,
   std::vector< typename _TImage::IndexType >& seeds
@@ -92,6 +93,6 @@ _ConfigureFilter(
   } // fi
 }
 
-#endif // __fpaPluginsImageAlgorithms__BaseFilter__h__
+#endif // __fpaPlugins_ImageAlgorithms__BaseFilter__h__
 
 // eof - $RCSfile$
index c15d96fb4506b1a3bb3d2c6f868c6388d620954d..7d4fe1edac38094020468f533a158550a974bb6a 100644 (file)
@@ -1,18 +1,19 @@
-#include <ImageAlgorithms/Dijkstra.h>
+#include "Dijkstra.h"
+#include <cpPlugins/Pipeline/Functor.h>
 #include <cpInstances/DataObjects/Image.h>
 
 #include <fpa/Image/Dijkstra.h>
 
 // -------------------------------------------------------------------------
-fpaPluginsImageAlgorithms::Dijkstra::
+fpaPlugins_ImageAlgorithms::Dijkstra::
 Dijkstra( )
   : Superclass( )
 {
-  typedef cpPlugins::Pipeline::DataObject _TData;
+  typedef cpPlugins::Pipeline::DataObject _TFunctor;
   typedef cpInstances::DataObjects::Image _TMST;
 
-  this->_ConfigureInput< _TData >( "VertexFunction", false, false );
-  this->_ConfigureInput< _TData >( "ConversionFunction", false, false );
+  this->_ConfigureInput< _TFunctor >( "VertexFunction", false, false );
+  this->_ConfigureInput< _TFunctor >( "ConversionFunction", false, false );
   this->_ConfigureOutput< _TMST >( "MST" );
 
   std::vector< std::string > choices;
@@ -23,13 +24,13 @@ Dijkstra( )
 }
 
 // -------------------------------------------------------------------------
-fpaPluginsImageAlgorithms::Dijkstra::
+fpaPlugins_ImageAlgorithms::Dijkstra::
 ~Dijkstra( )
 {
 }
 
 // -------------------------------------------------------------------------
-void fpaPluginsImageAlgorithms::Dijkstra::
+void fpaPlugins_ImageAlgorithms::Dijkstra::
 _GenerateData( )
 {
   auto o = this->GetInputData( "Input" );
@@ -39,7 +40,7 @@ _GenerateData( )
 
 // -------------------------------------------------------------------------
 template< class _TImage >
-void fpaPluginsImageAlgorithms::Dijkstra::
+void fpaPlugins_ImageAlgorithms::Dijkstra::
 _GD0( _TImage* image )
 {
   typedef itk::Image< float, _TImage::ImageDimension >  _TFloat;
@@ -52,35 +53,46 @@ _GD0( _TImage* image )
 
 // -------------------------------------------------------------------------
 template< class _TInputImage, class _TOutputImage >
-void fpaPluginsImageAlgorithms::Dijkstra::
+void fpaPlugins_ImageAlgorithms::Dijkstra::
 _GD1( _TInputImage* image )
 {
+  typedef cpPlugins::Pipeline::Functor _TFunctor;
   typedef fpa::Image::Dijkstra< _TInputImage, _TOutputImage > _TFilter;
   typedef typename _TFilter::TConversionFunction  _TConversionFunction;
   typedef typename _TFilter::TVertexFunction          _TVertexFunction;
 
+  // Create filter
   auto filter = this->_CreateITK< _TFilter >( );
   std::vector< typename _TInputImage::IndexType > seeds;
   this->_ConfigureFilter( filter, image, seeds );
+
+  // Instantiate functors
+  auto cost_conversion = this->GetInputData< _TFunctor >( "ConversionFunction" );
+  if( cost_conversion != NULL )
+  {
+    cost_conversion->Instantiate( filter );
+    auto cost_conversion_functor = cost_conversion->GetFunctor< _TConversionFunction >( );
+    if( cost_conversion_functor != NULL )
+      filter->SetConversionFunction( cost_conversion_functor );
+
+  } // fi
+
+  auto vertex = this->GetInputData< _TFunctor >( "VertexFunction" );
+  if( vertex != NULL )
+  {
+    vertex->Instantiate( filter );
+    auto vertex_functor = vertex->GetFunctor< _TVertexFunction >( );
+    if( vertex_functor != NULL )
+      filter->SetVertexFunction( vertex_functor );
+
+  } // fi
+
+  // Finish filter's configuration
   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$
index 5ac22331bcb81fd04c1fa58b6a53c592e162b52f..5482e8da40b72d41fbe25bb190d7217450cc8265 100644 (file)
@@ -1,13 +1,13 @@
-#ifndef __fpaPluginsImageAlgorithms__Dijkstra__h__
-#define __fpaPluginsImageAlgorithms__Dijkstra__h__
+#ifndef __fpaPlugins_ImageAlgorithms__Dijkstra__h__
+#define __fpaPlugins_ImageAlgorithms__Dijkstra__h__
 
 #include <ImageAlgorithms/BaseFilter.h>
 
-namespace fpaPluginsImageAlgorithms
+namespace fpaPlugins_ImageAlgorithms
 {
   /**
    */
-  class fpaPluginsImageAlgorithms_EXPORT Dijkstra
+  class fpaPlugins_ImageAlgorithms_EXPORT Dijkstra
     : public BaseFilter
   {
     cpPluginsObject( Dijkstra, BaseFilter, fpaImageAlgorithms );
@@ -16,12 +16,12 @@ namespace fpaPluginsImageAlgorithms
     template< class _TImage >
     inline void _GD0( _TImage* image );
 
-    template< class _TInputImage, class _TOutputPixel >
+    template< class _TInputImage, class _TOutputImage >
     inline void _GD1( _TInputImage* image );
   };
 
 } // ecapseman
 
-#endif // __fpaPluginsImageAlgorithms__Dijkstra__h__
+#endif // __fpaPlugins_ImageAlgorithms__Dijkstra__h__
 
 // eof - $RCSfile$
diff --git a/plugins/ImageAlgorithms/ExtractPathFromMinimumSpanningTree.cxx b/plugins/ImageAlgorithms/ExtractPathFromMinimumSpanningTree.cxx
new file mode 100644 (file)
index 0000000..55ca96e
--- /dev/null
@@ -0,0 +1,80 @@
+#include "ExtractPathFromMinimumSpanningTree.h"
+#include <cpInstances/DataObjects/Image.h>
+#include <cpInstances/DataObjects/PolyLineParametricPath.h>
+#include <vtkPolyData.h>
+#include <fpa/Image/MinimumSpanningTree.h>
+
+// -------------------------------------------------------------------------
+fpaPlugins_ImageAlgorithms::ExtractPathFromMinimumSpanningTree::
+ExtractPathFromMinimumSpanningTree( )
+  : Superclass( )
+{
+  typedef cpPlugins::Pipeline::DataObject             _TData;
+  typedef cpInstances::DataObjects::Image                  _TMST;
+  typedef cpInstances::DataObjects::PolyLineParametricPath _TPath;
+
+  this->_ConfigureInput< _TMST >( "MST", true, false );
+  this->_ConfigureInput< _TData >( "Seeds", true, false );
+  this->_ConfigureOutput< _TPath >( "Output" );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins_ImageAlgorithms::ExtractPathFromMinimumSpanningTree::
+~ExtractPathFromMinimumSpanningTree( )
+{
+}
+
+// -------------------------------------------------------------------------
+void fpaPlugins_ImageAlgorithms::ExtractPathFromMinimumSpanningTree::
+_GenerateData( )
+{
+  typedef fpa::Image::MinimumSpanningTree< 2 > _TMST2;
+  typedef fpa::Image::MinimumSpanningTree< 3 > _TMST3;
+
+  auto mst2 = this->GetInputData< _TMST2 >( "MST" );
+  auto mst3 = this->GetInputData< _TMST3 >( "MST" );
+  if     ( mst2 != NULL ) this->_GD0( mst2 );
+  else if( mst3 != NULL ) this->_GD0( mst3 );
+  else this->_Error( "Invalid input spanning tree." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TMST >
+void fpaPlugins_ImageAlgorithms::ExtractPathFromMinimumSpanningTree::
+_GD0( _TMST* mst )
+{
+  typedef typename _TMST::IndexType _TIndex;
+  typedef typename _TMST::TPath     _TPath;
+
+  // Get seeds
+  std::vector< _TIndex > seeds;
+  auto points = this->GetInputData< vtkPolyData >( "Seeds" );
+  if( points != NULL )
+  {
+    if( points->GetNumberOfPoints( ) < 2 )
+      this->_Error( "Not enough seeds (<2)." );
+
+    typename _TMST::PointType pnt;
+    typename _TMST::IndexType idx;
+    unsigned int dim =
+      ( _TMST::ImageDimension < 3 )? _TMST::ImageDimension: 3;
+    for( unsigned int i = 0; i < 2; ++i )
+    {
+      double buf[ 3 ];
+      points->GetPoint( i, buf );
+      pnt.Fill( 0 );
+      for( unsigned int d = 0; d < dim; ++d )
+        pnt[ d ] = buf[ d ];
+      if( mst->TransformPhysicalPointToIndex( pnt, idx ) )
+        seeds.push_back( idx );
+
+    } // rof
+
+  } // fi
+
+  typename _TPath::Pointer path;
+  mst->GetPath( path, seeds[ 0 ], seeds[ 1 ] );
+  this->GetOutput( "Output" )->SetITK( path );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/ImageAlgorithms/ExtractPathFromMinimumSpanningTree.h b/plugins/ImageAlgorithms/ExtractPathFromMinimumSpanningTree.h
new file mode 100644 (file)
index 0000000..a331457
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef __fpaPlugins_ImageAlgorithms__ExtractPathFromMinimumSpanningTree__h__
+#define __fpaPlugins_ImageAlgorithms__ExtractPathFromMinimumSpanningTree__h__
+
+#include <fpaPlugins_ImageAlgorithms_Export.h>
+#include <cpPlugins/Pipeline/ProcessObject.h>
+
+namespace fpaPlugins_ImageAlgorithms
+{
+  /**
+   */
+  class fpaPlugins_ImageAlgorithms_EXPORT ExtractPathFromMinimumSpanningTree
+    : public cpPlugins::Pipeline::ProcessObject
+  {
+    cpPluginsObject(
+      ExtractPathFromMinimumSpanningTree,
+      cpPlugins::Pipeline::ProcessObject,
+      fpaImageAlgorithms
+      );
+
+  protected:
+    template< class _TMST >
+    inline void _GD0( _TMST* mst );
+  };
+
+} // ecapseman
+
+#endif // __fpaPlugins_ImageAlgorithms__ExtractPathFromMinimumSpanningTree__h__
+
+// eof - $RCSfile$
index 5805e307adc2a629b68b61e3051b7d046f07a38a..355c882f3773b240f5e87e76004d020e698f0466 100644 (file)
@@ -1,19 +1,18 @@
-#include <ImageAlgorithms/FastMarching.h>
+#include "FastMarching.h"
+#include <cpPlugins/Pipeline/Functor.h>
 #include <cpInstances/DataObjects/Image.h>
 
 #include <fpa/Image/FastMarching.h>
 
 // -------------------------------------------------------------------------
-fpaPluginsImageAlgorithms::FastMarching::
+fpaPlugins_ImageAlgorithms::FastMarching::
 FastMarching( )
   : Superclass( )
 {
-  typedef cpPlugins::Pipeline::DataObject _TData;
-  typedef cpInstances::DataObjects::Image _TMST;
+  typedef cpPlugins::Pipeline::DataObject _TFunctor;
 
-  this->_ConfigureInput< _TData >( "VertexFunction", false, false );
-  this->_ConfigureInput< _TData >( "ConversionFunction", false, false );
-  this->_ConfigureOutput< _TMST >( "MST" );
+  this->_ConfigureInput< _TFunctor >( "VertexFunction", false, false );
+  this->_ConfigureInput< _TFunctor >( "ConversionFunction", false, false );
 
   std::vector< std::string > choices;
   choices.push_back( "float" );
@@ -23,13 +22,13 @@ FastMarching( )
 }
 
 // -------------------------------------------------------------------------
-fpaPluginsImageAlgorithms::FastMarching::
+fpaPlugins_ImageAlgorithms::FastMarching::
 ~FastMarching( )
 {
 }
 
 // -------------------------------------------------------------------------
-void fpaPluginsImageAlgorithms::FastMarching::
+void fpaPlugins_ImageAlgorithms::FastMarching::
 _GenerateData( )
 {
   auto o = this->GetInputData( "Input" );
@@ -39,7 +38,7 @@ _GenerateData( )
 
 // -------------------------------------------------------------------------
 template< class _TImage >
-void fpaPluginsImageAlgorithms::FastMarching::
+void fpaPlugins_ImageAlgorithms::FastMarching::
 _GD0( _TImage* image )
 {
   typedef itk::Image< float, _TImage::ImageDimension >  _TFloat;
@@ -52,35 +51,46 @@ _GD0( _TImage* image )
 
 // -------------------------------------------------------------------------
 template< class _TInputImage, class _TOutputImage >
-void fpaPluginsImageAlgorithms::FastMarching::
+void fpaPlugins_ImageAlgorithms::FastMarching::
 _GD1( _TInputImage* image )
 {
+  typedef cpPlugins::Pipeline::Functor _TFunctor;
   typedef fpa::Image::FastMarching< _TInputImage, _TOutputImage > _TFilter;
   typedef typename _TFilter::TConversionFunction      _TConversionFunction;
   typedef typename _TFilter::TVertexFunction              _TVertexFunction;
 
+  // Create filter
   auto filter = this->_CreateITK< _TFilter >( );
   std::vector< typename _TInputImage::IndexType > seeds;
   this->_ConfigureFilter( filter, image, seeds );
+
+  // Instantiate functors
+  auto cost_conversion = this->GetInputData< _TFunctor >( "ConversionFunction" );
+  if( cost_conversion != NULL )
+  {
+    cost_conversion->Instantiate( filter );
+    auto cost_conversion_functor = cost_conversion->GetFunctor< _TConversionFunction >( );
+    if( cost_conversion_functor != NULL )
+      filter->SetConversionFunction( cost_conversion_functor );
+
+  } // fi
+
+  auto vertex = this->GetInputData< _TFunctor >( "VertexFunction" );
+  if( vertex != NULL )
+  {
+    vertex->Instantiate( filter );
+    auto vertex_functor = vertex->GetFunctor< _TVertexFunction >( );
+    if( vertex_functor != NULL )
+      filter->SetVertexFunction( vertex_functor );
+
+  } // fi
+
+  // Finish filter's configuration
   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$
index 323897571cbfb7ee92720c23ab69e903a8153ad2..2bd620712ae06972534f9e3a345afed1ef0b1ff8 100644 (file)
@@ -1,13 +1,13 @@
-#ifndef __fpaPluginsImageAlgorithms__FastMarching__h__
-#define __fpaPluginsImageAlgorithms__FastMarching__h__
+#ifndef __fpaPlugins_ImageAlgorithms__FastMarching__h__
+#define __fpaPlugins_ImageAlgorithms__FastMarching__h__
 
 #include <ImageAlgorithms/BaseFilter.h>
 
-namespace fpaPluginsImageAlgorithms
+namespace fpaPlugins_ImageAlgorithms
 {
   /**
    */
-  class fpaPluginsImageAlgorithms_EXPORT FastMarching
+  class fpaPlugins_ImageAlgorithms_EXPORT FastMarching
     : public BaseFilter
   {
     cpPluginsObject( FastMarching, BaseFilter, fpaImageAlgorithms );
@@ -16,12 +16,12 @@ namespace fpaPluginsImageAlgorithms
     template< class _TImage >
     inline void _GD0( _TImage* image );
 
-    template< class _TInputImage, class _TOutputPixel >
+    template< class _TInputImage, class _TOutputImage >
     inline void _GD1( _TInputImage* image );
   };
 
 } // ecapseman
 
-#endif // __fpaPluginsImageAlgorithms__FastMarching__h__
+#endif // __fpaPlugins_ImageAlgorithms__FastMarching__h__
 
 // eof - $RCSfile$
diff --git a/plugins/ImageAlgorithms/MoriRegionGrow.cxx b/plugins/ImageAlgorithms/MoriRegionGrow.cxx
deleted file mode 100644 (file)
index cda8979..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-#include <ImageAlgorithms/MoriRegionGrow.h>
-#include <cpInstances/DataObjects/Image.h>
-
-#include <fpa/Image/MoriRegionGrow.h>
-
-// -------------------------------------------------------------------------
-fpaPluginsImageAlgorithms::MoriRegionGrow::
-MoriRegionGrow( )
-  : Superclass( )
-{
-  typedef cpPlugins::Pipeline::DataObject _TData;
-  typedef cpInstances::DataObjects::Image _TImage;
-
-  this->_ConfigureInput< _TImage >( "Input", true, false );
-  this->_ConfigureInput< _TData >( "Seed", true, false );
-  this->_ConfigureOutput< _TImage >( "Output" );
-  this->_ConfigureOutput< _TImage >( "AuxiliaryOutput" );
-
-  this->m_Parameters.ConfigureAsInt( "InsideValue", 1 );
-  this->m_Parameters.ConfigureAsInt( "OutsideValue", 0 );
-  this->m_Parameters.ConfigureAsReal( "Step", 1 );
-  this->m_Parameters.ConfigureAsReal( "Lower", 0 );
-  this->m_Parameters.ConfigureAsReal( "Upper", 1 );
-  this->m_Parameters.ConfigureAsIntTypesChoices( "ResultType" );
-}
-
-// -------------------------------------------------------------------------
-fpaPluginsImageAlgorithms::MoriRegionGrow::
-~MoriRegionGrow( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPluginsImageAlgorithms::MoriRegionGrow::
-_GenerateData( )
-{
-  auto o = this->GetInputData( "Input" );
-  cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
-    this->_Error( "Invalid input image." );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-void fpaPluginsImageAlgorithms::MoriRegionGrow::
-_GD0( _TImage* image )
-{
-  auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
-  if( rtype == "char" )        this->_GD1< _TImage, char >( image );
-  else if( rtype == "uchar" )  this->_GD1< _TImage, unsigned char >( image );
-  else if( rtype == "short" )  this->_GD1< _TImage, short >( image );
-  else if( rtype == "ushort" ) this->_GD1< _TImage, unsigned short >( image );
-  else if( rtype == "int" )    this->_GD1< _TImage, int >( image );
-  else if( rtype == "uint" )   this->_GD1< _TImage, unsigned int >( image );
-  else if( rtype == "long" )   this->_GD1< _TImage, long >( image );
-  else if( rtype == "ulong" )  this->_GD1< _TImage, unsigned long >( image );
-  else                         this->_GD1< _TImage, char >( image );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TOutputPixel >
-void fpaPluginsImageAlgorithms::MoriRegionGrow::
-_GD1( _TInputImage* image )
-{
-  /* 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" ) );
-
-     // 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." );
-
-     filter->Update( );
-     this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
-     this->GetOutput( "AuxiliaryOutput" )->SetITK( filter->GetAuxiliaryImage( ) );
-  */
-}
-
-// eof - $RCSfile$
diff --git a/plugins/ImageAlgorithms/MoriRegionGrow.h b/plugins/ImageAlgorithms/MoriRegionGrow.h
deleted file mode 100644 (file)
index f21c28b..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __fpaPluginsImageAlgorithms__MoriRegionGrow__h__
-#define __fpaPluginsImageAlgorithms__MoriRegionGrow__h__
-
-#include <ImageAlgorithms/BaseFilter.h>
-
-namespace fpaPluginsImageAlgorithms
-{
-  /**
-   */
-  class fpaPluginsImageAlgorithms_EXPORT MoriRegionGrow
-    : public cpPlugins::Pipeline::ProcessObject
-  {
-    cpPluginsObject(
-      MoriRegionGrow, cpPlugins::Pipeline::ProcessObject, fpaImageAlgorithms
-      );
-
-  protected:
-    template< class _TImage >
-    inline void _GD0( _TImage* image );
-
-    template< class _TInputImage, class _TOutputPixel >
-    inline void _GD1( _TInputImage* image );
-  };
-
-} // ecapseman
-
-#endif // __fpaPluginsImageAlgorithms__MoriRegionGrow__h__
-
-// eof - $RCSfile$
index e1aff3e3effc67bfea2eef7da2dd1e8fee73b2b3..bd0fc747d0afa3ca78e6c049c30693e2d42ad1e4 100644 (file)
@@ -1,29 +1,31 @@
-#include <ImageAlgorithms/RegionGrow.h>
+#include "RegionGrow.h"
+#include <cpPlugins/Pipeline/Functor.h>
 #include <cpInstances/DataObjects/Image.h>
 
 #include <fpa/Image/RegionGrow.h>
 
 // -------------------------------------------------------------------------
-fpaPluginsImageAlgorithms::RegionGrow::
+fpaPlugins_ImageAlgorithms::RegionGrow::
 RegionGrow( )
   : Superclass( )
 {
-  typedef cpPlugins::Pipeline::DataObject _TData;
+  typedef cpPlugins::Pipeline::DataObject _TFunctor;
+  typedef cpInstances::DataObjects::Image _TMST;
 
-  this->_ConfigureInput< _TData >( "GrowFunction", true, false );
+  this->_ConfigureInput< _TFunctor >( "GrowFunction", true, false );
   this->m_Parameters.ConfigureAsInt( "InsideValue", 1 );
   this->m_Parameters.ConfigureAsInt( "OutsideValue", 0 );
   this->m_Parameters.ConfigureAsIntTypesChoices( "ResultType" );
 }
 
 // -------------------------------------------------------------------------
-fpaPluginsImageAlgorithms::RegionGrow::
+fpaPlugins_ImageAlgorithms::RegionGrow::
 ~RegionGrow( )
 {
 }
 
 // -------------------------------------------------------------------------
-void fpaPluginsImageAlgorithms::RegionGrow::
+void fpaPlugins_ImageAlgorithms::RegionGrow::
 _GenerateData( )
 {
   auto o = this->GetInputData( "Input" );
@@ -33,7 +35,7 @@ _GenerateData( )
 
 // -------------------------------------------------------------------------
 template< class _TImage >
-void fpaPluginsImageAlgorithms::RegionGrow::
+void fpaPlugins_ImageAlgorithms::RegionGrow::
 _GD0( _TImage* image )
 {
   auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
@@ -50,27 +52,34 @@ _GD0( _TImage* image )
 
 // -------------------------------------------------------------------------
 template< class _TInputImage, class _TOutputPixel >
-void fpaPluginsImageAlgorithms::RegionGrow::
+void fpaPlugins_ImageAlgorithms::RegionGrow::
 _GD1( _TInputImage* image )
 {
-  typedef
-    itk::Image< _TOutputPixel, _TInputImage::ImageDimension >
-    _TOutputImage;
+  typedef cpPlugins::Pipeline::Functor _TFunctor;
+  typedef itk::Image< _TOutputPixel, _TInputImage::ImageDimension > _TOutputImage;
   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" ) );
+  typedef typename _TFilter::TGrowFunction _TGrowFunction;
 
+  // Create filter
   auto filter = this->_CreateITK< _TFilter >( );
   std::vector< typename _TInputImage::IndexType > seeds;
   this->_ConfigureFilter( filter, image, seeds );
+
+  // Instantiate functors
+  auto growfunc = this->GetInputData< _TFunctor >( "GrowFunction" );
+  if( growfunc != NULL )
+  {
+    growfunc->Instantiate( filter );
+    auto growfunc_functor = growfunc->GetFunctor< _TGrowFunction >( );
+    if( growfunc_functor != NULL )
+      filter->SetGrowFunction( growfunc_functor );
+
+  } // fi
+
+  // Finish filter's configuration
   filter->ClearSeeds( );
   for( auto seed : seeds )
-    filter->AddSeed( seed, i_val );
-  filter->SetGrowFunction( this->GetInputData< _TGrow >( "GrowFunction" ) );
-  filter->SetInsideValue( i_val );
-  filter->SetOutsideValue( o_val );
+    filter->AddSeed( seed, ( typename _TOutputImage::PixelType )( 0 ) );
   filter->Update( );
   this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
 }
index f5b49af4fe677c599b38e6a40f2f81caa4465e62..c9e59a7bc7515cc34480372e776a0c224111432e 100644 (file)
@@ -1,13 +1,13 @@
-#ifndef __fpaPluginsImageAlgorithms__RegionGrow__h__
-#define __fpaPluginsImageAlgorithms__RegionGrow__h__
+#ifndef __fpaPlugins_ImageAlgorithms__RegionGrow__h__
+#define __fpaPlugins_ImageAlgorithms__RegionGrow__h__
 
 #include <ImageAlgorithms/BaseFilter.h>
 
-namespace fpaPluginsImageAlgorithms
+namespace fpaPlugins_ImageAlgorithms
 {
   /**
    */
-  class fpaPluginsImageAlgorithms_EXPORT RegionGrow
+  class fpaPlugins_ImageAlgorithms_EXPORT RegionGrow
     : public BaseFilter
   {
     cpPluginsObject( RegionGrow, BaseFilter, fpaImageAlgorithms );
@@ -22,6 +22,6 @@ namespace fpaPluginsImageAlgorithms
 
 } // ecapseman
 
-#endif // __fpaPluginsImageAlgorithms__RegionGrow__h__
+#endif // __fpaPlugins_ImageAlgorithms__RegionGrow__h__
 
 // eof - $RCSfile$
diff --git a/plugins/ImageAlgorithms/SkeletonFilter.cxx b/plugins/ImageAlgorithms/SkeletonFilter.cxx
deleted file mode 100644 (file)
index 03689aa..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <ImageAlgorithms/SkeletonFilter.h>
-#include <cpInstances/DataObjects/Image.h>
-#include <cpInstances/DataObjects/Skeleton.h>
-
-#include <itkImage.h>
-
-/* TODO
-   #include <fpa/Image/SkeletonFilter.h>
-   #include <vtkPolyData.h>
-*/
-
-// -------------------------------------------------------------------------
-fpaPluginsImageAlgorithms::SkeletonFilter::
-SkeletonFilter( )
-  : Superclass( )
-{
-  typedef cpInstances::DataObjects::Image    _TImage;
-  typedef cpInstances::DataObjects::Skeleton _TSkeleton;
-  typedef cpPlugins::Pipeline::DataObject _TData;
-
-  this->_ConfigureInput< _TImage >( "Input", true, false );
-  this->_ConfigureInput< _TData >( "Seeds", true, false );
-  this->_ConfigureOutput< _TSkeleton >( "Skeleton" );
-  this->_ConfigureOutput< _TImage >( "Marks" );
-}
-
-// -------------------------------------------------------------------------
-fpaPluginsImageAlgorithms::SkeletonFilter::
-~SkeletonFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-void fpaPluginsImageAlgorithms::SkeletonFilter::
-_GenerateData( )
-{
-  auto o = this->GetInputData( "Input" );
-  cpPlugins_Demangle_Image_RealPixels_AllDims_1( o, _GD0 )
-    this->_Error( "Invalid input image." );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-void fpaPluginsImageAlgorithms::SkeletonFilter::
-_GD0( _TImage* 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;
-
-     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 );
-
-     } // rof
-
-     } // fi
-
-     filter->Update( );
-     this->GetOutput( "Skeleton" )->SetITK( filter->GetSkeleton( ) );
-     this->GetOutput( "Marks" )->SetITK( filter->GetMarks( ) );
-  */
-}
-
-// eof - $RCSfile$
diff --git a/plugins/ImageAlgorithms/SkeletonFilter.h b/plugins/ImageAlgorithms/SkeletonFilter.h
deleted file mode 100644 (file)
index cd3ebcf..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __fpaPluginsImageAlgorithms__SkeletonFilter__h__
-#define __fpaPluginsImageAlgorithms__SkeletonFilter__h__
-
-#include <fpaPluginsImageAlgorithms_Export.h>
-#include <cpPlugins/Pipeline/ProcessObject.h>
-
-namespace fpaPluginsImageAlgorithms
-{
-  /**
-   */
-  class fpaPluginsImageAlgorithms_EXPORT SkeletonFilter
-    : public cpPlugins::Pipeline::ProcessObject
-  {
-    cpPluginsObject(
-      SkeletonFilter,
-      cpPlugins::Pipeline::ProcessObject,
-      fpaImageAlgorithms
-      );
-
-  protected:
-    template< class _TImage >
-    inline void _GD0( _TImage* image );
-  };
-
-} // ecapseman
-
-#endif // __fpaPluginsImageAlgorithms__SkeletonFilter__h__
-
-// eof - $RCSfile$
diff --git a/plugins/ImageFunctors/BinaryThreshold.cxx b/plugins/ImageFunctors/BinaryThreshold.cxx
new file mode 100644 (file)
index 0000000..4d4589e
--- /dev/null
@@ -0,0 +1,90 @@
+#include "BinaryThreshold.h"
+
+#include <cpInstances/DataObjects/Image.h>
+
+#include <itkImage.h>
+#include <fpa/Image/Functors/RegionGrow/BinaryThreshold.h>
+
+// -------------------------------------------------------------------------
+void fpaPlugins_ImageFunctors::BinaryThreshold::
+Instantiate( itk::LightObject* filter )
+{
+  auto itk_filter = dynamic_cast< itk::ProcessObject* >( filter );
+  if( itk_filter != NULL )
+  {
+    auto inputs = itk_filter->GetInputs( );
+    if( inputs.size( ) > 0 )
+    {
+      cpPlugins_Demangle_Image_ScalarPixels_AllDims_2(
+        inputs[ 0 ].GetPointer( ), _GD0, itk_filter
+        )
+        this->_Error( "Invalid input data." );
+    }
+    else
+      this->_Error( "Not enough inputs." );
+  }
+  else
+    this->_Error( "Invalid instantiation filter." );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins_ImageFunctors::BinaryThreshold::
+BinaryThreshold( )
+  : Superclass( )
+{
+  this->_ConfigureOutput< cpPlugins::Pipeline::DataObject >( "Functor" );
+  this->GetOutput( "Functor" )->SetITK( this );
+  this->m_Parameters.ConfigureAsReal( "Lower", 0 );
+  this->m_Parameters.ConfigureAsReal( "Upper", 1 );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins_ImageFunctors::BinaryThreshold::
+~BinaryThreshold( )
+{
+}
+
+// -------------------------------------------------------------------------
+void fpaPlugins_ImageFunctors::BinaryThreshold::
+_GenerateData( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TInput >
+void fpaPlugins_ImageFunctors::BinaryThreshold::
+_GD0( _TInput* input, itk::ProcessObject* filter )
+{
+  auto outputs = filter->GetOutputs( );
+  if( outputs.size( ) > 0 )
+  {
+    cpPlugins_Demangle_Image_IntPixels_3(
+      outputs[ 0 ].GetPointer( ), _GD1, _TInput::ImageDimension, input, filter
+      )
+      this->_Error( "Invalid output data." );
+  }
+  else
+    this->_Error( "Not enough outputs." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInput, class _TOutput >
+void fpaPlugins_ImageFunctors::BinaryThreshold::
+_GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter )
+{
+  typedef typename _TOutput::PixelType _TValue;
+  typedef fpa::Image::Functors::RegionGrow::BinaryThreshold< _TInput, _TValue > _TFunctor;
+
+  auto f = dynamic_cast< _TFunctor* >( this->m_Functor.GetPointer( ) );
+  if( f == NULL )
+  {
+    typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
+    f = ptr_f.GetPointer( );
+    this->m_Functor = f;
+
+  } // fi
+  f->SetLower( this->m_Parameters.GetReal( "Lower" ) );
+  f->SetUpper( this->m_Parameters.GetReal( "Upper" ) );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/ImageFunctors/BinaryThreshold.h b/plugins/ImageFunctors/BinaryThreshold.h
new file mode 100644 (file)
index 0000000..73cdad1
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef __fpaPlugins_ImageFunctors__BinaryThreshold__h__
+#define __fpaPlugins_ImageFunctors__BinaryThreshold__h__
+
+#include <itkProcessObject.h>
+#include <fpaPlugins_ImageFunctors_Export.h>
+#include <cpPlugins/Pipeline/Functor.h>
+
+namespace fpaPlugins_ImageFunctors
+{
+  /**
+   */
+  class fpaPlugins_ImageFunctors_EXPORT BinaryThreshold
+    : public cpPlugins::Pipeline::Functor
+  {
+    cpPluginsObject( BinaryThreshold, cpPlugins::Pipeline::Functor, fpaImageFunctors );
+
+  public:
+    virtual void Instantiate( itk::LightObject* filter ) override;
+
+  protected:
+    template< class _TInput >
+    inline void _GD0( _TInput* input, itk::ProcessObject* filter );
+
+    template< class _TInput, class _TOutput >
+    inline void _GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter );
+  };
+
+} // ecapseman
+
+#endif // __fpaPlugins_ImageFunctors__BinaryThreshold__h__
+
+// eof - $RCSfile$
diff --git a/plugins/ImageFunctors/Tautology.cxx b/plugins/ImageFunctors/Tautology.cxx
new file mode 100644 (file)
index 0000000..6763602
--- /dev/null
@@ -0,0 +1,87 @@
+#include "Tautology.h"
+
+#include <cpInstances/DataObjects/Image.h>
+
+#include <itkImage.h>
+#include <fpa/Base/Functors/RegionGrow/Tautology.h>
+
+// -------------------------------------------------------------------------
+void fpaPlugins_ImageFunctors::Tautology::
+Instantiate( itk::LightObject* filter )
+{
+  auto itk_filter = dynamic_cast< itk::ProcessObject* >( filter );
+  if( itk_filter != NULL )
+  {
+    auto inputs = itk_filter->GetInputs( );
+    if( inputs.size( ) > 0 )
+    {
+      cpPlugins_Demangle_Image_ScalarPixels_AllDims_2(
+        inputs[ 0 ].GetPointer( ), _GD0, itk_filter
+        )
+        this->_Error( "Invalid input data." );
+    }
+    else
+      this->_Error( "Not enough inputs." );
+  }
+  else
+    this->_Error( "Invalid instantiation filter." );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins_ImageFunctors::Tautology::
+Tautology( )
+  : Superclass( )
+{
+  this->_ConfigureOutput< cpPlugins::Pipeline::DataObject >( "Functor" );
+  this->GetOutput( "Functor" )->SetITK( this );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins_ImageFunctors::Tautology::
+~Tautology( )
+{
+}
+
+// -------------------------------------------------------------------------
+void fpaPlugins_ImageFunctors::Tautology::
+_GenerateData( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TInput >
+void fpaPlugins_ImageFunctors::Tautology::
+_GD0( _TInput* input, itk::ProcessObject* filter )
+{
+  auto outputs = filter->GetOutputs( );
+  if( outputs.size( ) > 0 )
+  {
+    cpPlugins_Demangle_Image_IntPixels_3(
+      outputs[ 0 ].GetPointer( ), _GD1, _TInput::ImageDimension, input, filter
+      )
+      this->_Error( "Invalid output data." );
+  }
+  else
+    this->_Error( "Not enough outputs." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInput, class _TOutput >
+void fpaPlugins_ImageFunctors::Tautology::
+_GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter )
+{
+  typedef typename _TInput::IndexType  _TVertex;
+  typedef typename _TOutput::PixelType _TValue;
+  typedef fpa::Base::Functors::RegionGrow::Tautology< _TVertex, _TValue > _TFunctor;
+
+  auto f = dynamic_cast< _TFunctor* >( this->m_Functor.GetPointer( ) );
+  if( f == NULL )
+  {
+    typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
+    f = ptr_f.GetPointer( );
+    this->m_Functor = f;
+
+  } // fi
+}
+
+// eof - $RCSfile$
diff --git a/plugins/ImageFunctors/Tautology.h b/plugins/ImageFunctors/Tautology.h
new file mode 100644 (file)
index 0000000..1a846c1
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef __fpaPlugins_ImageFunctors__Tautology__h__
+#define __fpaPlugins_ImageFunctors__Tautology__h__
+
+#include <itkProcessObject.h>
+#include <fpaPlugins_ImageFunctors_Export.h>
+#include <cpPlugins/Pipeline/Functor.h>
+
+namespace fpaPlugins_ImageFunctors
+{
+  /**
+   */
+  class fpaPlugins_ImageFunctors_EXPORT Tautology
+    : public cpPlugins::Pipeline::Functor
+  {
+    cpPluginsObject( Tautology, cpPlugins::Pipeline::Functor, fpaImageFunctors );
+
+  public:
+    virtual void Instantiate( itk::LightObject* filter ) override;
+
+  protected:
+    template< class _TInput >
+    inline void _GD0( _TInput* input, itk::ProcessObject* filter );
+
+    template< class _TInput, class _TOutput >
+    inline void _GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter );
+  };
+
+} // ecapseman
+
+#endif // __fpaPlugins_ImageFunctors__Tautology__h__
+
+// eof - $RCSfile$
diff --git a/plugins/ImageFunctors/VertexCost.cxx b/plugins/ImageFunctors/VertexCost.cxx
new file mode 100644 (file)
index 0000000..222cdb5
--- /dev/null
@@ -0,0 +1,89 @@
+#include "VertexCost.h"
+
+#include <cpInstances/DataObjects/Image.h>
+
+#include <itkImage.h>
+#include <fpa/Image/Functors/VertexCost.h>
+
+// -------------------------------------------------------------------------
+void fpaPlugins_ImageFunctors::VertexCost::
+Instantiate( itk::LightObject* filter )
+{
+  auto itk_filter = dynamic_cast< itk::ProcessObject* >( filter );
+  if( itk_filter != NULL )
+  {
+    auto inputs = itk_filter->GetInputs( );
+    if( inputs.size( ) > 0 )
+    {
+      cpPlugins_Demangle_Image_ScalarPixels_AllDims_2(
+        inputs[ 0 ].GetPointer( ), _GD0, itk_filter
+        )
+        this->_Error( "Invalid input data." );
+    }
+    else
+      this->_Error( "Not enough inputs." );
+  }
+  else
+    this->_Error( "Invalid instantiation filter." );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins_ImageFunctors::VertexCost::
+VertexCost( )
+  : Superclass( )
+{
+  this->_ConfigureOutput< cpPlugins::Pipeline::DataObject >( "Functor" );
+  this->m_Parameters.ConfigureAsBool( "UseImageSpacing", false );
+  this->GetOutput( "Functor" )->SetITK( this );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins_ImageFunctors::VertexCost::
+~VertexCost( )
+{
+}
+
+// -------------------------------------------------------------------------
+void fpaPlugins_ImageFunctors::VertexCost::
+_GenerateData( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TInput >
+void fpaPlugins_ImageFunctors::VertexCost::
+_GD0( _TInput* input, itk::ProcessObject* filter )
+{
+  auto outputs = filter->GetOutputs( );
+  if( outputs.size( ) > 0 )
+  {
+    cpPlugins_Demangle_Image_ScalarPixels_3(
+      outputs[ 0 ].GetPointer( ), _GD1, _TInput::ImageDimension, input, filter
+      )
+      this->_Error( "Invalid output data." );
+  }
+  else
+    this->_Error( "Not enough outputs." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInput, class _TOutput >
+void fpaPlugins_ImageFunctors::VertexCost::
+_GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter )
+{
+  typedef typename _TInput::PixelType  _TIValue;
+  typedef typename _TOutput::PixelType _TOValue;
+  typedef fpa::Image::Functors::VertexCost< _TInput, _TOValue > _TFunctor;
+
+  auto f = dynamic_cast< _TFunctor* >( this->m_Functor.GetPointer( ) );
+  if( f == NULL )
+  {
+    typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
+    f = ptr_f.GetPointer( );
+    this->m_Functor = f;
+
+  } // fi
+  f->SetUseImageSpacing( this->m_Parameters.GetReal( "UseImageSpacing" ) );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/ImageFunctors/VertexCost.h b/plugins/ImageFunctors/VertexCost.h
new file mode 100644 (file)
index 0000000..7a0bc14
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef __fpaPlugins_ImageFunctors__VertexCost__h__
+#define __fpaPlugins_ImageFunctors__VertexCost__h__
+
+#include <itkProcessObject.h>
+#include <fpaPlugins_ImageFunctors_Export.h>
+#include <cpPlugins/Pipeline/Functor.h>
+
+namespace fpaPlugins_ImageFunctors
+{
+  /**
+   */
+  class fpaPlugins_ImageFunctors_EXPORT VertexCost
+    : public cpPlugins::Pipeline::Functor
+  {
+    cpPluginsObject( VertexCost, cpPlugins::Pipeline::Functor, fpaImageFunctors );
+
+  public:
+    virtual void Instantiate( itk::LightObject* filter ) override;
+
+  protected:
+    template< class _TInput >
+    inline void _GD0( _TInput* input, itk::ProcessObject* filter );
+
+    template< class _TInput, class _TOutput >
+    inline void _GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter );
+  };
+
+} // ecapseman
+
+#endif // __fpaPlugins_ImageFunctors__VertexCost__h__
+
+// eof - $RCSfile$