]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Wed, 9 Nov 2016 22:59:29 +0000 (17:59 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Wed, 9 Nov 2016 22:59:29 +0000 (17:59 -0500)
15 files changed:
lib/fpa/Base/Functors/GaussianModel.h
lib/fpa/Base/Functors/GaussianModel.hxx
lib/fpa/Base/RegionGrow.h [new file with mode: 0644]
lib/fpa/Base/RegionGrow.hxx [new file with mode: 0644]
lib/fpa/Base/RegionGrowFunctionBase.h [new file with mode: 0644]
lib/fpa/Image/Dijkstra.h
lib/fpa/Image/Functors/RegionGrowBinaryThreshold.h [new file with mode: 0644]
lib/fpa/Image/Functors/RegionGrowBinaryThreshold.hxx [new file with mode: 0644]
lib/fpa/Image/RegionGrow.h [new file with mode: 0644]
lib/fpa/Image/RegionGrow.hxx [new file with mode: 0644]
plugins/Plugins/ImageRegionGrow.cxx [new file with mode: 0644]
plugins/Plugins/ImageRegionGrow.h [new file with mode: 0644]
plugins/Plugins/RegionGrowBinaryThreshold.cxx [new file with mode: 0644]
plugins/Plugins/RegionGrowBinaryThreshold.h [new file with mode: 0644]
plugins/Plugins/fpaPlugins.i

index f147b26a3ab8c42e7caae835340e8028a2e7c0fe..a74e5176bde7d1a0699d762cff0c4b1f90e08792 100644 (file)
@@ -35,12 +35,14 @@ namespace fpa
         itkNewMacro( Self );
         itkTypeMacro( GaussianModel, itk::FunctionBase );
 
-        itkGetConstMacro( SupportSize, unsigned int );
-        itkGetConstMacro( MinimumCost, TOutput );
-        itkGetObjectMacro( Model, TModel );
-        itkGetConstObjectMacro( Model, TModel );
-        itkSetMacro( SupportSize, unsigned int );
-        itkSetMacro( MinimumCost, TOutput );
+        /* TODO
+           itkGetConstMacro( SupportSize, unsigned int );
+           itkGetConstMacro( MinimumCost, TOutput );
+           itkGetObjectMacro( Model, TModel );
+           itkGetConstObjectMacro( Model, TModel );
+           itkSetMacro( SupportSize, unsigned int );
+           itkSetMacro( MinimumCost, TOutput );
+        */
 
       public:
         virtual TOutput Evaluate( const TInput& x ) const fpa_OVERRIDE;
@@ -55,9 +57,14 @@ namespace fpa
         Self& operator=( const Self& other );
 
       protected:
-        unsigned int m_SupportSize;
-        TOutput m_MinimumCost;
-        typename TModel::Pointer m_Model;
+        /* TODO
+           unsigned int m_SupportSize;
+           TOutput m_MinimumCost;
+           typename TModel::Pointer m_Model;
+        */
+        mutable double m_S1;
+        mutable double m_S2;
+        mutable unsigned long m_N;
       };
 
     } // ecapseman
index 49db8b04cbe5cd3afa41679b8847010611c1c971..e9706a547f04a84bdb4739d522ed102b124c9341 100644 (file)
@@ -7,35 +7,86 @@ typename fpa::Base::Functors::GaussianModel< _TInput, _TOutput >::
 TOutput fpa::Base::Functors::GaussianModel< _TInput, _TOutput >::
 Evaluate( const TInput& x ) const
 {
-  TOutput r = TOutput( 0 );
-  if( this->m_Model->GetNumberOfSamples( ) > this->m_SupportSize )
+  double v = double( x );
+  double d = double( 0 );
+  if( this->m_N > 1 )
   {
-    r = this->m_Model->SquaredMahalanobis( TOutput( x ) );
-    if( r <= TOutput( 1 ) )
-      this->m_Model->AddSample( TOutput( x ) );
+    double N = double( this->m_N );
+    double m = this->m_S1 / N;
+    double s =
+      ( this->m_S2 - ( ( this->m_S1 * this->m_S1 ) / N ) ) /
+      ( N - double( 1 ) );
+    if( s > double( 0 ) )
+    {
+      d = ( v - m );
+      d *= d;
+      d /= s;
+      d = std::sqrt( d );
+      if( d <= double( 2 ) ) // 2sigma
+      {
+        this->m_S1 += v;
+        this->m_S2 += v * v;
+        this->m_N += 1;
+
+      } // fi
+    }
+    else
+    {
+      this->m_S1 += v;
+      this->m_S2 += v * v;
+      this->m_N += 1;
+
+    } // fi
   }
   else
   {
-    this->m_Model->AddSample( TOutput( x ) );
-    if( this->m_Model->GetNumberOfSamples( ) > 2 )
-      r = this->m_Model->SquaredMahalanobis( TOutput( x ) );
+    this->m_S1 += v;
+    this->m_S2 += v * v;
+    this->m_N += 1;
 
   } // fi
-  if( r < this->m_MinimumCost )
-    return( this->m_MinimumCost );
-  else
-    return( r );
+  std::cout << v << " " << d << std::endl;
+  return( d );
+
+  /* TODO
+     TOutput r = TOutput( 0 );
+     if( this->m_Model->GetNumberOfSamples( ) > this->m_SupportSize )
+     {
+     r = this->m_Model->SquaredMahalanobis( TOutput( x ) );
+     if( r <= TOutput( 1 ) )
+     this->m_Model->AddSample( TOutput( x ) );
+     }
+     else
+     {
+     this->m_Model->AddSample( TOutput( x ) );
+     if( this->m_Model->GetNumberOfSamples( ) > 2 )
+     r = this->m_Model->SquaredMahalanobis( TOutput( x ) );
+
+     } // fi
+     if( r < this->m_MinimumCost )
+     return( this->m_MinimumCost );
+     else
+     return( r );
+  */
 }
 
 // -------------------------------------------------------------------------
 template< class _TInput, class _TOutput >
 fpa::Base::Functors::GaussianModel< _TInput, _TOutput >::
 GaussianModel( )
-  : Superclass( ),
-    m_SupportSize( 30 ),
-    m_MinimumCost( TOutput( 1e-10 ) )
+  : Superclass( )
+  /* TODO
+     ,
+     m_SupportSize( 30 ),
+     m_MinimumCost( TOutput( 1e-10 ) )
+  */
 {
-  this->m_Model = TModel::New( );
+  /* TODO
+     this->m_Model = TModel::New( );
+  */
+  this->m_S1 = double( 0 );
+  this->m_S2 = double( 0 );
+  this->m_N = 0;
 }
 
 // -------------------------------------------------------------------------
diff --git a/lib/fpa/Base/RegionGrow.h b/lib/fpa/Base/RegionGrow.h
new file mode 100644 (file)
index 0000000..5cd36de
--- /dev/null
@@ -0,0 +1,78 @@
+#ifndef __fpa__Base__RegionGrow__h__
+#define __fpa__Base__RegionGrow__h__
+
+#include <queue>
+#include <fpa/Config.h>
+#include <fpa/Base/RegionGrowFunctionBase.h>
+
+namespace fpa
+{
+  namespace Base
+  {
+    /**
+     */
+    template< class _TSuperclass >
+    class RegionGrow
+      : public _TSuperclass
+    {
+    public:
+      typedef RegionGrow                      Self;
+      typedef _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::RegionGrowFunctionBase< TVertex > 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 );
+
+      itkSetObjectMacro( GrowFunction, TGrowFunction );
+      itkSetMacro( InsideValue, TOutput );
+      itkSetMacro( OutsideValue, TOutput );
+
+    protected:
+      RegionGrow( );
+      virtual ~RegionGrow( );
+
+      virtual bool _UpdateValue(
+        _TQueueNode& v, const _TQueueNode& p
+        ) fpa_OVERRIDE;
+      virtual unsigned long _QueueSize( ) const fpa_OVERRIDE;
+      virtual void _QueueClear( ) fpa_OVERRIDE;
+      virtual void _QueuePush( const _TQueueNode& node ) fpa_OVERRIDE;
+      virtual _TQueueNode _QueuePop( ) fpa_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
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Base/RegionGrow.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Base__RegionGrow__h__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Base/RegionGrow.hxx b/lib/fpa/Base/RegionGrow.hxx
new file mode 100644 (file)
index 0000000..b0beaf2
--- /dev/null
@@ -0,0 +1,79 @@
+#ifndef __fpa__Base__RegionGrow__hxx__
+#define __fpa__Base__RegionGrow__hxx__
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+fpa::Base::RegionGrow< _TSuperclass >::
+RegionGrow( )
+  : Superclass( ),
+    m_InsideValue( TOutput( 1 ) ),
+    m_OutsideValue( TOutput( 0 ) )
+{
+  this->m_InitResult = TOutput( 0 );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+fpa::Base::RegionGrow< _TSuperclass >::
+~RegionGrow( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+bool fpa::Base::RegionGrow< _TSuperclass >::
+_UpdateValue( _TQueueNode& v, const _TQueueNode& p )
+{
+  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 );
+  }
+  else
+  {
+    v.Result = this->m_InitResult;
+    return( false );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+unsigned long fpa::Base::RegionGrow< _TSuperclass >::
+_QueueSize( ) const
+{
+  return( this->m_Queue.size( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+void fpa::Base::RegionGrow< _TSuperclass >::
+_QueueClear( )
+{
+  while( this->m_Queue.size( ) > 0 )
+    this->m_Queue.pop( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+void fpa::Base::RegionGrow< _TSuperclass >::
+_QueuePush( const _TQueueNode& node )
+{
+  this->m_Queue.push( node );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+typename fpa::Base::RegionGrow< _TSuperclass >::
+_TQueueNode fpa::Base::RegionGrow< _TSuperclass >::
+_QueuePop( )
+{
+  _TQueueNode f = this->m_Queue.front( );
+  this->m_Queue.pop( );
+  return( f );
+}
+
+#endif // __fpa__Base__RegionGrow__hxx__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Base/RegionGrowFunctionBase.h b/lib/fpa/Base/RegionGrowFunctionBase.h
new file mode 100644 (file)
index 0000000..5c2ef52
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef __fpa__Base__RegionGrowFunctionBase__h__
+#define __fpa__Base__RegionGrowFunctionBase__h__
+
+#include <itkObject.h>
+#include <itkObjectFactory.h>
+
+namespace fpa
+{
+  namespace Base
+  {
+    /**
+     */
+    template< class _TVertex >
+    class RegionGrowFunctionBase
+      : public itk::Object
+    {
+    public:
+      typedef RegionGrowFunctionBase        Self;
+      typedef itk::Object                     Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
+
+      typedef _TVertex TVertex;
+
+    public:
+      itkTypeMacro( RegionGrowFunctionBase, itk::Object );
+
+    public:
+      virtual bool Evaluate( const TVertex& a, const TVertex& b ) const = 0;
+
+    protected:
+      RegionGrowFunctionBase( )
+        : Superclass( )
+        { }
+      virtual ~RegionGrowFunctionBase( )
+        { }
+
+    private:
+      // Purposely not defined
+      RegionGrowFunctionBase( const Self& other );
+      Self& operator=( const Self& other );
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __fpa__Base__RegionGrowFunctionBase__h__
+
+// eof - $RCSfile$
index 37c28e808458eeed85c4713f5b8bf1a123fc36a7..253f97380b312e4e252ef5944fcc2f2d348084ba 100644 (file)
@@ -29,9 +29,6 @@ namespace fpa
 
       typedef fpa::Image::Functors::Base< _TInputImage, fpa::Base::DijkstraCostFunctionBase< TVertex, TOutput > > TCostFunction;
 
-    protected:
-      typedef typename Superclass::_TQueueNode _TQueueNode;
-
     public:
       itkNewMacro( Self );
       itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra );
diff --git a/lib/fpa/Image/Functors/RegionGrowBinaryThreshold.h b/lib/fpa/Image/Functors/RegionGrowBinaryThreshold.h
new file mode 100644 (file)
index 0000000..201e3d8
--- /dev/null
@@ -0,0 +1,70 @@
+#ifndef __fpa__Image__Functors__RegionGrowBinaryThreshold__h__
+#define __fpa__Image__Functors__RegionGrowBinaryThreshold__h__
+
+#include <fpa/Image/Functors/Base.h>
+#include <fpa/Base/RegionGrowFunctionBase.h>
+
+namespace fpa
+{
+  namespace Image
+  {
+    namespace Functors
+    {
+      /**
+       */
+      template< class _TImage >
+      class RegionGrowBinaryThreshold
+        : public fpa::Image::Functors::Base< _TImage, fpa::Base::RegionGrowFunctionBase< typename _TImage::IndexType > >
+      {
+      public:
+        typedef _TImage                    TImage;
+        typedef typename TImage::IndexType TIndex;
+        typedef typename TImage::PixelType TPixel;
+
+        typedef fpa::Base::RegionGrowFunctionBase< TIndex >      TBaseFunctor;
+        typedef fpa::Image::Functors::Base< TImage, TBaseFunctor > Superclass;
+        typedef RegionGrowBinaryThreshold       Self;
+        typedef itk::SmartPointer< Self >       Pointer;
+        typedef itk::SmartPointer< const Self > ConstPointer;
+
+      public:
+        itkNewMacro( Self );
+        itkTypeMacro( RegionGrowBinaryThreshold, Base );
+
+        itkGetConstMacro( LowerThreshold, TPixel );
+        itkGetConstMacro( UpperThreshold, TPixel );
+        itkSetMacro( LowerThreshold, TPixel );
+        itkSetMacro( UpperThreshold, TPixel );
+
+      public:
+        virtual bool Evaluate(
+          const TIndex& a, const TIndex& b
+          ) const fpa_OVERRIDE;
+
+      protected:
+        RegionGrowBinaryThreshold( );
+        virtual ~RegionGrowBinaryThreshold( );
+
+      private:
+        // Purposely not implemented
+        RegionGrowBinaryThreshold( const Self& other );
+        Self& operator=( const Self& other );
+
+      protected:
+        TPixel m_LowerThreshold;
+        TPixel m_UpperThreshold;
+      };
+
+    } // ecapseman
+
+  } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Image/Functors/RegionGrowBinaryThreshold.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Image__Functors__RegionGrowBinaryThreshold__h__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Image/Functors/RegionGrowBinaryThreshold.hxx b/lib/fpa/Image/Functors/RegionGrowBinaryThreshold.hxx
new file mode 100644 (file)
index 0000000..53e3b2e
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef __fpa__Image__Functors__RegionGrowBinaryThreshold__hxx__
+#define __fpa__Image__Functors__RegionGrowBinaryThreshold__hxx__
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+bool fpa::Image::Functors::RegionGrowBinaryThreshold< _TImage >::
+Evaluate( const TIndex& a, const TIndex& b ) const
+{
+  const _TImage* im =
+    dynamic_cast< const _TImage* >( this->m_Image.GetPointer( ) );
+  TPixel v = im->GetPixel( b );
+  return( this->m_LowerThreshold <= v && v <= this->m_UpperThreshold );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+fpa::Image::Functors::RegionGrowBinaryThreshold< _TImage >::
+RegionGrowBinaryThreshold( )
+  : Superclass( ),
+    m_LowerThreshold( TPixel( 0 ) ),
+    m_UpperThreshold( std::numeric_limits< TPixel >::max( ) )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+fpa::Image::Functors::RegionGrowBinaryThreshold< _TImage >::
+~RegionGrowBinaryThreshold( )
+{
+}
+
+#endif // __fpa__Image__Functors__RegionGrowBinaryThreshold__hxx__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Image/RegionGrow.h b/lib/fpa/Image/RegionGrow.h
new file mode 100644 (file)
index 0000000..ad41e80
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef __fpa__Image__RegionGrow__h__
+#define __fpa__Image__RegionGrow__h__
+
+#include <fpa/Base/RegionGrow.h>
+#include <fpa/Image/Algorithm.h>
+
+namespace fpa
+{
+  namespace Image
+  {
+    /**
+     */
+    template< class _TInputImage, class _TOutputImage >
+    class RegionGrow
+      : public fpa::Base::RegionGrow< fpa::Image::Algorithm< _TInputImage, _TOutputImage > >
+    {
+    public:
+      typedef fpa::Image::Algorithm< _TInputImage, _TOutputImage > TAlgorithm;
+      typedef RegionGrow                          Self;
+      typedef fpa::Base::RegionGrow< TAlgorithm > Superclass;
+      typedef itk::SmartPointer< Self >           Pointer;
+      typedef itk::SmartPointer< const Self >     ConstPointer;
+
+      typedef typename Superclass::TOutput TOutput;
+      typedef typename Superclass::TVertex TVertex;
+
+      typedef fpa::Image::Functors::Base< _TInputImage, typename Superclass::TGrowFunction > TGrowFunction;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( fpa::Image::RegionGrow, fpa::Base::RegionGrow );
+
+    protected:
+      RegionGrow( );
+      virtual ~RegionGrow( );
+
+      virtual void _BeforeGenerateData( ) fpa_OVERRIDE;
+
+    private:
+      // Purposely not defined
+      RegionGrow( const Self& other );
+      Self& operator=( const Self& other );
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Image/RegionGrow.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Image__RegionGrow__h__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Image/RegionGrow.hxx b/lib/fpa/Image/RegionGrow.hxx
new file mode 100644 (file)
index 0000000..b1f5da0
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef __fpa__Image__RegionGrow__hxx__
+#define __fpa__Image__RegionGrow__hxx__
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+fpa::Image::RegionGrow< _TInputImage, _TOutputImage >::
+RegionGrow( )
+  : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+fpa::Image::RegionGrow< _TInputImage, _TOutputImage >::
+~RegionGrow( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+void fpa::Image::RegionGrow< _TInputImage, _TOutputImage >::
+_BeforeGenerateData( )
+{
+  this->Superclass::_BeforeGenerateData( );
+
+  TGrowFunction* grow =
+    dynamic_cast< TGrowFunction* >( this->GetGrowFunction( ) );
+  if( grow != NULL )
+    grow->SetImage( this->GetInput( ) );
+}
+
+#endif // __fpa__Image__RegionGrow__hxx__
+
+// eof - $RCSfile$
diff --git a/plugins/Plugins/ImageRegionGrow.cxx b/plugins/Plugins/ImageRegionGrow.cxx
new file mode 100644 (file)
index 0000000..df1713c
--- /dev/null
@@ -0,0 +1,115 @@
+#include <Plugins/ImageRegionGrow.h>
+#include <cpPlugins/DataObjects/Image.h>
+#include <cpPlugins/DataObjects/Image_Demanglers.h>
+
+#include <fpa/Image/RegionGrow.h>
+#include <vtkPolyData.h>
+
+// -------------------------------------------------------------------------
+fpaPlugins::ImageRegionGrow::
+ImageRegionGrow( )
+  : Superclass( )
+{
+  typedef cpPlugins::BaseObjects::DataObject _TData;
+  typedef cpPlugins::DataObjects::Image      _TMST;
+
+  this->_ConfigureInput< _TData >( "GrowFunction", true, false );
+
+  this->m_Parameters.ConfigureAsInt( "InsideValue", 1 );
+  this->m_Parameters.ConfigureAsInt( "OutsideValue", 0 );
+  this->m_Parameters.ConfigureAsIntTypesChoices( "ResultType" );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins::ImageRegionGrow::
+~ImageRegionGrow( )
+{
+}
+
+// -------------------------------------------------------------------------
+void fpaPlugins::ImageRegionGrow::
+_GenerateData( )
+{
+  auto o = this->GetInputData( "Input" );
+  cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
+    this->_Error( "Invalid input image." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void fpaPlugins::ImageRegionGrow::
+_GD0( _TImage* image )
+{
+  auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_char
+  if( rtype == "char" ) this->_GD1< _TImage, char >( image );
+  if( rtype == "uchar" ) this->_GD1< _TImage, unsigned char >( image );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_char
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_short
+  if( rtype == "short" ) this->_GD1< _TImage, short >( image );
+  if( rtype == "ushort" ) this->_GD1< _TImage, unsigned short >( image );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_short
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_int
+  if( rtype == "int" ) this->_GD1< _TImage, int >( image );
+  if( rtype == "uint" ) this->_GD1< _TImage, unsigned int >( image );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_int
+#ifdef cpPlugins_CONFIG_INTEGER_TYPES_long
+  if( rtype == "long" ) this->_GD1< _TImage, long >( image );
+  if( rtype == "ulong" ) this->_GD1< _TImage, unsigned long >( image );
+#endif // cpPlugins_CONFIG_INTEGER_TYPES_long
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputPixel >
+void fpaPlugins::ImageRegionGrow::
+_GD1( _TInputImage* image )
+{
+  typedef
+    itk::Image< _TOutputPixel, _TInputImage::ImageDimension >
+    _TOutputImage;
+  typedef fpa::Image::RegionGrow< _TInputImage, _TOutputImage > _TFilter;
+  typedef typename _TFilter::TGrowFunction           _TGrow;
+  typedef typename _TFilter::TNeighborhoodFunction   _TNeighborhood;
+
+  // Get functors
+  auto neig = this->GetInputData< _TNeighborhood >( "Neighborhood" );
+  auto grow = this->GetInputData< _TGrow >( "GrowFunction" );
+
+  // Configure filter
+  auto filter = this->_CreateITK< _TFilter >( );
+  filter->SetInput( image );
+  filter->SetGrowFunction( grow );
+  filter->SetInsideValue( this->m_Parameters.GetInt( "InsideValue" ) );
+  filter->SetOutsideValue( this->m_Parameters.GetInt( "OutsideValue" ) );
+  filter->SetStopAtOneFront( this->m_Parameters.GetBool( "StopAtOneFront" ) );
+
+  // Assign seeds
+  auto seeds = this->GetInputData< vtkPolyData >( "Seeds" );
+  if( seeds != NULL )
+  {
+    typename _TInputImage::PointType pnt;
+    typename _TInputImage::IndexType idx;
+    unsigned int dim =
+      ( _TInputImage::ImageDimension < 3 )? _TInputImage::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
+
+  // Assign outputs
+  filter->Update( );
+  this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/Plugins/ImageRegionGrow.h b/plugins/Plugins/ImageRegionGrow.h
new file mode 100644 (file)
index 0000000..d2a9661
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef __fpa__Plugins__ImageRegionGrow__h__
+#define __fpa__Plugins__ImageRegionGrow__h__
+
+#include <Plugins/BaseImageFilter.h>
+
+namespace fpaPlugins
+{
+  /**
+   */
+  class fpaPlugins_EXPORT ImageRegionGrow
+    : public BaseImageFilter
+  {
+    cpPluginsObject( ImageRegionGrow, BaseImageFilter, fpa );
+
+  protected:
+    template< class _TImage >
+    inline void _GD0( _TImage* image );
+
+    template< class _TInputImage, class _TOutputPixel >
+    inline void _GD1( _TInputImage* image );
+  };
+
+} // ecapseman
+
+#endif // __fpa__Plugins__ImageRegionGrow__h__
+
+// eof - $RCSfile$
diff --git a/plugins/Plugins/RegionGrowBinaryThreshold.cxx b/plugins/Plugins/RegionGrowBinaryThreshold.cxx
new file mode 100644 (file)
index 0000000..8f7c620
--- /dev/null
@@ -0,0 +1,59 @@
+#include <Plugins/RegionGrowBinaryThreshold.h>
+#include <cpPlugins/DataObjects/Image.h>
+#include <cpPlugins/DataObjects/Image_Demanglers.h>
+
+#include <itkImage.h>
+#include <fpa/Image/Functors/RegionGrowBinaryThreshold.h>
+
+// -------------------------------------------------------------------------
+fpaPlugins::RegionGrowBinaryThreshold::
+RegionGrowBinaryThreshold( )
+  : Superclass( )
+{
+  typedef cpPlugins::BaseObjects::DataObject _TData;
+  typedef cpPlugins::DataObjects::Image _TImage;
+
+  this->_ConfigureInput< _TImage >( "Input", true, false );
+  this->_ConfigureOutput< _TData >( "Output" );
+
+  this->m_Parameters.ConfigureAsReal( "LowerThreshold", 0 );
+  this->m_Parameters.ConfigureAsReal( "UpperThreshold", 0 );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins::RegionGrowBinaryThreshold::
+~RegionGrowBinaryThreshold( )
+{
+}
+
+// -------------------------------------------------------------------------
+void fpaPlugins::RegionGrowBinaryThreshold::
+_GenerateData( )
+{
+  auto o = this->GetInputData( "Input" );
+  cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
+    this->_Error( "Invalid input image." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void fpaPlugins::RegionGrowBinaryThreshold::
+_GD0( _TImage* image )
+{
+  typedef
+    fpa::Image::Functors::RegionGrowBinaryThreshold< _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
+  f->SetLowerThreshold( this->m_Parameters.GetReal( "LowerThreshold" ) );
+  f->SetUpperThreshold( this->m_Parameters.GetReal( "UpperThreshold" ) );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/Plugins/RegionGrowBinaryThreshold.h b/plugins/Plugins/RegionGrowBinaryThreshold.h
new file mode 100644 (file)
index 0000000..17c19e0
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef __fpa__Plugins__RegionGrowBinaryThreshold__h__
+#define __fpa__Plugins__RegionGrowBinaryThreshold__h__
+
+#include <fpaPlugins_Export.h>
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+
+namespace fpaPlugins
+{
+  /**
+   */
+  class fpaPlugins_EXPORT RegionGrowBinaryThreshold
+    : public cpPlugins::BaseObjects::ProcessObject
+  {
+    cpPluginsObject(
+      RegionGrowBinaryThreshold,
+      cpPlugins::BaseObjects::ProcessObject,
+      fpaFunctors
+      );
+
+  protected:
+    template< class _TImage >
+    inline void _GD0( _TImage* image );
+  };
+
+} // ecapseman
+
+#endif // __fpa__Plugins__RegionGrowBinaryThreshold__h__
+
+// eof - $RCSfile$
index b01b712547dad2d7917bb95e1c07026a670cdc43..34a013acdc4637879d7c3ed1b0742a262a33ab5c 100644 (file)
@@ -7,20 +7,26 @@ tinclude fpa/Image/Functors/SimpleNeighborhood:h|hxx
 tinclude fpa/Image/Functors/SimpleDijkstraCost:h|hxx
 tinclude fpa/Base/Functors/Inverse:h|hxx
 tinclude fpa/Base/Functors/GaussianModel:h|hxx
+tinclude fpa/Image/RegionGrow:h|hxx
 tinclude fpa/Image/Dijkstra:h|hxx
 tinclude fpa/Image/SkeletonFilter:h|hxx
+tinclude fpa/Image/Functors/RegionGrowBinaryThreshold:h|hxx
 
 cinclude itkImage.h
 cinclude itkSimpleDataObjectDecorator.hxx
+cinclude fpa/Base/RegionGrow.hxx
 cinclude fpa/Base/Dijkstra.hxx
 
 instances fpa::Image::Functors::SimpleNeighborhood< itk::Image< #scalar_pixels#, #process_dims# > >
 instances fpa::Image::Functors::SimpleDijkstraCost< itk::Image< #scalar_pixels#, #process_dims# >, #real_types# >
+instances fpa::Image::Functors::RegionGrowBinaryThreshold< itk::Image< #scalar_pixels#, #process_dims# > >
 
 instances fpa::Base::Functors::Inverse< #i_real#, #o_real# >
 instances fpa::Base::Functors::GaussianModel< #i_real#, #o_real# >
 
 instances fpa::Image::Dijkstra< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #real_types#, #process_dims# > >
+instances fpa::Image::RegionGrow< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #int_types#, #process_dims# > >
+instances fpa::Image::RegionGrow< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #uint_types#, #process_dims# > >
 instances fpa::Image::SkeletonFilter< itk::Image< #real_types#, #process_dims# > >
 
 ** eof - $RCSfile$