]> Creatis software - FrontAlgorithms.git/commitdiff
Mori is alivegit status!
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Fri, 3 Feb 2017 22:25:32 +0000 (17:25 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Fri, 3 Feb 2017 22:25:32 +0000 (17:25 -0500)
23 files changed:
CMakeLists.txt
examples/CMakeLists.txt [new file with mode: 0644]
examples/RegionGrow_00.cxx [new file with mode: 0644]
lib/fpa/Base/Algorithm.h
lib/fpa/Base/Algorithm.hxx
lib/fpa/Base/Functors/RegionGrow/Base.h [new file with mode: 0644]
lib/fpa/Base/Functors/RegionGrow/Tautology.h [new file with mode: 0644]
lib/fpa/Base/MoriRegionGrow.h [new file with mode: 0644]
lib/fpa/Base/MoriRegionGrow.hxx [new file with mode: 0644]
lib/fpa/Base/RegionGrow.h
lib/fpa/Base/RegionGrow.hxx
lib/fpa/Base/RegionGrowFunctionBase.h [deleted file]
lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.h [new file with mode: 0644]
lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.hxx [new file with mode: 0644]
lib/fpa/Image/Functors/RegionGrowBinaryThreshold.h [deleted file]
lib/fpa/Image/Functors/RegionGrowBinaryThreshold.hxx [deleted file]
lib/fpa/Image/MoriRegionGrow.h [new file with mode: 0644]
lib/fpa/Image/MoriRegionGrow.hxx [new file with mode: 0644]
plugins/ImageAlgorithms/ImageAlgorithms.i
plugins/ImageAlgorithms/MoriRegionGrow.cxx [new file with mode: 0644]
plugins/ImageAlgorithms/MoriRegionGrow.h [new file with mode: 0644]
plugins/RegionGrowFunctors/BinaryThreshold.cxx
plugins/RegionGrowFunctors/RegionGrowFunctors.i

index 667002b8fa406ef26186f952e5845a6d9ece29c2..811b889fd7bfb0fa78e75120e6768face6ad2ff5 100644 (file)
@@ -8,7 +8,7 @@ SET(prj_NAME FrontAlgorithms)
 SET(prj_MAJOR_VERSION   0)
 SET(prj_MINOR_VERSION   1)
 SET(prj_RELEASE_VERSION 0)
-SET(_subdirs lib plugins)
+SET(_subdirs lib plugins examples)
 SET(_policies CMP0015 CMP0020 CMP0042)
 
 ## ==========================
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644 (file)
index 0000000..24e670a
--- /dev/null
@@ -0,0 +1,18 @@
+OPTION(BUILD_Examples "Build simple examples?" OFF)
+
+IF(BUILD_Examples)
+  SET(
+    _examples
+    RegionGrow_00
+    )
+  INCLUDE_DIRECTORIES(
+    ${PROJECT_SOURCE_DIR}/lib
+    ${PROJECT_BINARY_DIR}/lib
+    )
+  FOREACH(_example ${_examples})
+    ADD_EXECUTABLE(fpa_example_${_example} ${_example}.cxx)
+    TARGET_LINK_LIBRARIES(fpa_example_${_example} ${ITK_LIBRARIES})
+  ENDFOREACH(_example)
+ENDIF(BUILD_Examples)
+
+## eof - $RCSfile$
diff --git a/examples/RegionGrow_00.cxx b/examples/RegionGrow_00.cxx
new file mode 100644 (file)
index 0000000..eab6d41
--- /dev/null
@@ -0,0 +1,100 @@
+#include <itkCommand.h>
+#include <itkImage.h>
+#include <itkImageFileWriter.h>
+#include <fpa/Image/RegionGrow.h>
+
+// -------------------------------------------------------------------------
+typedef itk::Image< unsigned char, 2 >           TImage;
+typedef fpa::Image::RegionGrow< TImage, TImage > TFilter;
+typedef itk::ImageFileWriter< TImage >           TWriter;
+
+// -------------------------------------------------------------------------
+/**
+ */
+class MyObserver
+  : public itk::Command
+{
+public:
+  typedef TFilter::TStartEvent     TStartEvent;
+  typedef TFilter::TEndEvent       TEndEvent;
+  typedef TFilter::TStartLoopEvent TStartLoopEvent;
+  typedef TFilter::TEndLoopEvent   TEndLoopEvent;
+  typedef TFilter::TPushEvent      TPushEvent;
+  typedef TFilter::TPopEvent       TPopEvent;
+  typedef TFilter::TMarkEvent      TMarkEvent;
+
+public:
+  itkNewMacro( MyObserver );
+
+public:
+  virtual void Execute(
+    itk::Object* caller, const itk::EventObject& event
+    ) override
+    {
+      this->Execute( const_cast< const itk::Object* >( caller ), event );
+    }
+  virtual void Execute(
+    const itk::Object* object, const itk::EventObject& event
+    ) override
+    {
+      if( TStartEvent( ).CheckEvent( &event ) )
+        std::cout << "Start" << std::endl;
+      else if( TEndEvent( ).CheckEvent( &event ) )
+        std::cout << "End" << std::endl;
+      else if( TStartLoopEvent( ).CheckEvent( &event ) )
+        std::cout << "StartLoop" << std::endl;
+      else if( TEndLoopEvent( ).CheckEvent( &event ) )
+        std::cout << "EndLoop" << std::endl;
+      else if( TMarkEvent( ).CheckEvent( &event ) )
+      {
+        const TMarkEvent* mark = dynamic_cast< const TMarkEvent* >( &event );
+        std::cout << "Mark: " << mark->Vertex << std::endl;
+
+      } // fi
+      /* TODO
+         TPushEvent;
+         TPopEvent;
+      */
+    }
+};
+
+// -------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+  TImage::SizeType size;
+  size.Fill( 10 );
+
+  TImage::Pointer input = TImage::New( );
+  input->SetRegions( size );
+  input->Allocate( );
+  input->FillBuffer( 0 );
+
+  TImage::RegionType region = input->GetLargestPossibleRegion( );
+  TImage::PointType p0, p1, p2;
+  input->TransformIndexToPhysicalPoint( region.GetIndex( ), p0 );
+  input->TransformIndexToPhysicalPoint(
+    region.GetIndex( ) + region.GetSize( ), p1
+    );
+  p2 = ( p0.GetVectorFromOrigin( ) + p1.GetVectorFromOrigin( ) ) * 0.5;
+  TImage::IndexType seed;
+  input->TransformPhysicalPointToIndex( p2, seed );
+
+  TFilter::Pointer filter = TFilter::New( );
+  filter->SetInput( input );
+  filter->SetInsideValue( 255 );
+  filter->SetOutsideValue( 0 );
+  filter->AddSeed( seed, filter->GetInsideValue( ) );
+
+  MyObserver::Pointer obs = MyObserver::New( );
+  filter->AddObserver( itk::AnyEvent( ), obs );
+  filter->Update( );
+
+  TWriter::Pointer writer = TWriter::New( );
+  writer->SetInput( filter->GetOutput( ) );
+  writer->SetFileName( "RegionGrow_00.png" );
+  writer->Update( );
+
+  return( 0 );
+}
+
+// eof - $RCSfile$
index 662bdf1434273c7866abd12a18e073b074b0d08a..297727ac22ef0a5019d4b71f60e793b49c846ae4 100644 (file)
@@ -78,6 +78,7 @@ namespace fpa
       virtual void GenerateData( ) fpa_OVERRIDE;
 
       // Particular methods
+      virtual bool _ContinueGenerateData( );
       virtual void _Loop( );
 
       virtual void _BeforeGenerateData( );
index 4ad828c773dbae60c5ec2c90b796649e094079c1..30f42b7008e29eb45cd98bcd17bfb78afc36da3e 100644 (file)
@@ -95,13 +95,23 @@ GenerateData( )
     this->_InitResults( this->m_InitResult );
 
     // Main loop
-    this->_Loop( );
+    do
+      this->_Loop( );
+    while( this->_ContinueGenerateData( ) );
 
   } // fi
   this->_AfterGenerateData( );
   this->InvokeEvent( TEndEvent( ) );
 }
 
+// -------------------------------------------------------------------------
+template < class _TFilter, class _TVertex, class _TOutput >
+bool fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
+_ContinueGenerateData( )
+{
+  return( false );
+}
+
 // -------------------------------------------------------------------------
 template < class _TFilter, class _TVertex, class _TOutput >
 void fpa::Base::Algorithm< _TFilter, _TVertex, _TOutput >::
diff --git a/lib/fpa/Base/Functors/RegionGrow/Base.h b/lib/fpa/Base/Functors/RegionGrow/Base.h
new file mode 100644 (file)
index 0000000..7daf46e
--- /dev/null
@@ -0,0 +1,60 @@
+#ifndef __fpa__Base__Functors__RegionGrow__Base__h__
+#define __fpa__Base__Functors__RegionGrow__Base__h__
+
+#include <itkObject.h>
+#include <itkObjectFactory.h>
+
+namespace fpa
+{
+  namespace Base
+  {
+    namespace Functors
+    {
+      namespace RegionGrow
+      {
+        /**
+         */
+        template< class _TVertex >
+        class Base
+          : public itk::Object
+        {
+        public:
+          typedef Base                            Self;
+          typedef itk::Object                     Superclass;
+          typedef itk::SmartPointer< Self >       Pointer;
+          typedef itk::SmartPointer< const Self > ConstPointer;
+
+          typedef _TVertex TVertex;
+
+        public:
+          itkTypeMacro( Base, itk::Object );
+
+        public:
+          virtual bool Evaluate(
+            const TVertex& a, const TVertex& b
+            ) const = 0;
+
+        protected:
+          Base( )
+            : Superclass( )
+            { }
+          virtual ~Base( )
+            { }
+
+        private:
+          // Purposely not defined
+          Base( const Self& other );
+          Self& operator=( const Self& other );
+        };
+
+      } // ecapseman
+
+    } // ecapseman
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __fpa__Base__Functors__RegionGrow__Base__h__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Base/Functors/RegionGrow/Tautology.h b/lib/fpa/Base/Functors/RegionGrow/Tautology.h
new file mode 100644 (file)
index 0000000..744d618
--- /dev/null
@@ -0,0 +1,63 @@
+#ifndef __fpa__Base__Functors__RegionGrow__Tautology__h__
+#define __fpa__Base__Functors__RegionGrow__Tautology__h__
+
+#include <fpa/Base/Functors/RegionGrow/Base.h>
+
+namespace fpa
+{
+  namespace Base
+  {
+    namespace Functors
+    {
+      namespace RegionGrow
+      {
+        /**
+         */
+        template< class _TVertex >
+        class Tautology
+          : public Base< _TVertex >
+        {
+        public:
+          typedef Tautology                       Self;
+          typedef Base< _TVertex >                Superclass;
+          typedef itk::SmartPointer< Self >       Pointer;
+          typedef itk::SmartPointer< const Self > ConstPointer;
+
+          typedef typename Superclass::TVertex TVertex;
+
+        public:
+          itkNewMacro( Self );
+          itkTypeMacro( Tautology, Base );
+
+        public:
+          virtual bool Evaluate(
+            const TVertex& a, const TVertex& b
+            ) const override
+            {
+              return( true );
+            }
+
+        protected:
+          Tautology( )
+            : Superclass( )
+            { }
+          virtual ~Tautology( )
+            { }
+
+        private:
+          // Purposely not defined
+          Tautology( const Self& other );
+          Self& operator=( const Self& other );
+        };
+
+      } // ecapseman
+
+    } // ecapseman
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __fpa__Base__Functors__RegionGrow__Tautology__h__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Base/MoriRegionGrow.h b/lib/fpa/Base/MoriRegionGrow.h
new file mode 100644 (file)
index 0000000..40f59cd
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef __fpa__Base__MoriRegionGrow__h__
+#define __fpa__Base__MoriRegionGrow__h__
+
+#include <queue>
+#include <fpa/Config.h>
+#include <fpa/Base/RegionGrow.h>
+
+namespace fpa
+{
+  namespace Base
+  {
+    /**
+     */
+    template< class _TSuperclass >
+    class MoriRegionGrow
+      : public fpa::Base::RegionGrow< _TSuperclass >
+    {
+    public:
+      typedef MoriRegionGrow                        Self;
+      typedef fpa::Base::RegionGrow< _TSuperclass > Superclass;
+      typedef itk::SmartPointer< Self >             Pointer;
+      typedef itk::SmartPointer< const Self >       ConstPointer;
+
+      typedef typename Superclass::TOutput TOutput;
+      typedef typename Superclass::TVertex TVertex;
+
+    protected:
+      typedef typename Superclass::_TQueueNode _TQueueNode;
+      typedef typename Superclass::_TQueue     _TQueue;
+
+    public:
+      itkTypeMacro( MoriRegionGrow, Algorithm );
+
+    protected:
+      MoriRegionGrow( );
+      virtual ~MoriRegionGrow( );
+
+      virtual bool _UpdateValue(
+        _TQueueNode& v, const _TQueueNode& p
+        ) override;
+
+    private:
+      // Purposely not defined
+      MoriRegionGrow( const Self& other );
+      Self& operator=( const Self& other );
+
+    protected:
+      _TQueue m_AuxilaryQueue;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Base/MoriRegionGrow.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Base__MoriRegionGrow__h__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Base/MoriRegionGrow.hxx b/lib/fpa/Base/MoriRegionGrow.hxx
new file mode 100644 (file)
index 0000000..9e1c300
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef __fpa__Base__MoriRegionGrow__hxx__
+#define __fpa__Base__MoriRegionGrow__hxx__
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+fpa::Base::MoriRegionGrow< _TSuperclass >::
+MoriRegionGrow( )
+  : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+fpa::Base::MoriRegionGrow< _TSuperclass >::
+~MoriRegionGrow( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSuperclass >
+bool fpa::Base::MoriRegionGrow< _TSuperclass >::
+_UpdateValue( _TQueueNode& v, const _TQueueNode& p )
+{
+  bool ret = this->Superclass::_UpdateValue( v, p );
+  if( !ret )
+    this->m_AuxilaryQueue.push( v );
+  return( ret );
+}
+
+
+#endif // __fpa__Base__MoriRegionGrow__hxx__
+
+// eof - $RCSfile$
index 5cd36de8a2c202cea2e69ff418920fde0e2c27e2..2ef070399aa6416c5ed310b92657c4d26ea90ba9 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <queue>
 #include <fpa/Config.h>
-#include <fpa/Base/RegionGrowFunctionBase.h>
+#include <fpa/Base/Functors/RegionGrow/Base.h>
 
 namespace fpa
 {
@@ -24,7 +24,7 @@ namespace fpa
       typedef typename Superclass::TOutput TOutput;
       typedef typename Superclass::TVertex TVertex;
 
-      typedef fpa::Base::RegionGrowFunctionBase< TVertex > TGrowFunction;
+      typedef fpa::Base::Functors::RegionGrow::Base< TVertex > TGrowFunction;
 
     protected:
       typedef typename Superclass::_TQueueNode _TQueueNode;
index b0beaf29db7e2fc38477df7a13f95474ec5b5bcb..e7dba1fa3fbb6a7453846a2e00507352d5dec9d9 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __fpa__Base__RegionGrow__hxx__
 #define __fpa__Base__RegionGrow__hxx__
 
+#include <fpa/Base/Functors/RegionGrow/Tautology.h>
+
 // -------------------------------------------------------------------------
 template< class _TSuperclass >
 fpa::Base::RegionGrow< _TSuperclass >::
@@ -10,6 +12,9 @@ RegionGrow( )
     m_OutsideValue( TOutput( 0 ) )
 {
   this->m_InitResult = TOutput( 0 );
+  this->SetGrowFunction(
+    fpa::Base::Functors::RegionGrow::Tautology< TVertex >::New( )
+    );
 }
 
 // -------------------------------------------------------------------------
diff --git a/lib/fpa/Base/RegionGrowFunctionBase.h b/lib/fpa/Base/RegionGrowFunctionBase.h
deleted file mode 100644 (file)
index 5c2ef52..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#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$
diff --git a/lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.h b/lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.h
new file mode 100644 (file)
index 0000000..78c42a7
--- /dev/null
@@ -0,0 +1,74 @@
+#ifndef __fpa__Image__Functors__RegionGrow__BinaryThreshold__h__
+#define __fpa__Image__Functors__RegionGrow__BinaryThreshold__h__
+
+#include <fpa/Image/Functors/Base.h>
+#include <fpa/Base/Functors/RegionGrow/Base.h>
+
+namespace fpa
+{
+  namespace Image
+  {
+    namespace Functors
+    {
+      namespace RegionGrow
+      {
+        /**
+         */
+        template< class _TImage >
+        class BinaryThreshold
+          : public fpa::Image::Functors::Base< _TImage, fpa::Base::Functors::RegionGrow::Base< typename _TImage::IndexType > >
+        {
+        public:
+          typedef _TImage                    TImage;
+          typedef typename TImage::IndexType TIndex;
+          typedef typename TImage::PixelType TPixel;
+
+          typedef fpa::Base::Functors::RegionGrow::Base< TIndex > TBase;
+          typedef fpa::Image::Functors::Base< TImage, TBase > Superclass;
+          typedef BinaryThreshold                             Self;
+          typedef itk::SmartPointer< Self >                   Pointer;
+          typedef itk::SmartPointer< const Self >             ConstPointer;
+
+        public:
+          itkNewMacro( Self );
+          itkTypeMacro( BinaryThreshold, Base );
+
+          itkGetConstMacro( Lower, TPixel );
+          itkGetConstMacro( Upper, TPixel );
+          itkSetMacro( Lower, TPixel );
+          itkSetMacro( Upper, TPixel );
+
+        public:
+          virtual bool Evaluate(
+            const TIndex& a, const TIndex& b
+            ) const override;
+
+        protected:
+          BinaryThreshold( );
+          virtual ~BinaryThreshold( );
+
+        private:
+          // Purposely not implemented
+          BinaryThreshold( const Self& other );
+          Self& operator=( const Self& other );
+
+        protected:
+          TPixel m_Lower;
+          TPixel m_Upper;
+        };
+
+      } // ecapseman
+
+    } // ecapseman
+
+  } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Image/Functors/RegionGrow/BinaryThreshold.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Image__Functors__RegionGrow__BinaryThreshold__h__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.hxx b/lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.hxx
new file mode 100644 (file)
index 0000000..97cf465
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef __fpa__Image__Functors__RegionGrow__BinaryThreshold__hxx__
+#define __fpa__Image__Functors__RegionGrow__BinaryThreshold__hxx__
+
+#include <limits>
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+bool fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage >::
+Evaluate( const TIndex& a, const TIndex& b ) const
+{
+  const _TImage* im =
+    dynamic_cast< const _TImage* >( this->m_Image.GetPointer( ) );
+  if( im != NULL )
+  {
+    TPixel v = im->GetPixel( b );
+    return( this->m_Lower <= v && v <= this->m_Upper );
+  }
+  else
+    return( false );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage >::
+BinaryThreshold( )
+  : Superclass( )
+{
+  this->m_Upper = std::numeric_limits< TPixel >::max( );
+  if( std::numeric_limits< TPixel >::is_integer )
+    this->m_Lower = std::numeric_limits< TPixel >::min( );
+  else
+    this->m_Lower = -this->m_Upper;
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage >::
+~BinaryThreshold( )
+{
+}
+
+#endif // __fpa__Image__Functors__RegionGrow__BinaryThreshold__hxx__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Image/Functors/RegionGrowBinaryThreshold.h b/lib/fpa/Image/Functors/RegionGrowBinaryThreshold.h
deleted file mode 100644 (file)
index 201e3d8..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#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
deleted file mode 100644 (file)
index 53e3b2e..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#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/MoriRegionGrow.h b/lib/fpa/Image/MoriRegionGrow.h
new file mode 100644 (file)
index 0000000..5708582
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef __fpa__Image__MoriRegionGrow__h__
+#define __fpa__Image__MoriRegionGrow__h__
+
+#include <fpa/Base/MoriRegionGrow.h>
+#include <fpa/Image/Algorithm.h>
+
+namespace fpa
+{
+  namespace Image
+  {
+    /**
+     */
+    template< class _TInputImage, class _TOutputImage >
+    class MoriRegionGrow
+      : public fpa::Base::MoriRegionGrow< fpa::Image::Algorithm< _TInputImage, _TOutputImage > >
+    {
+    public:
+      typedef fpa::Image::Algorithm< _TInputImage, _TOutputImage > TAlgorithm;
+      typedef MoriRegionGrow                          Self;
+      typedef fpa::Base::MoriRegionGrow< 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::MoriRegionGrow, fpa::Base::MoriRegionGrow );
+
+    protected:
+      MoriRegionGrow( );
+      virtual ~MoriRegionGrow( );
+
+      virtual void _BeforeGenerateData( ) fpa_OVERRIDE;
+
+    private:
+      // Purposely not defined
+      MoriRegionGrow( const Self& other );
+      Self& operator=( const Self& other );
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Image/MoriRegionGrow.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Image__MoriRegionGrow__h__
+
+// eof - $RCSfile$
diff --git a/lib/fpa/Image/MoriRegionGrow.hxx b/lib/fpa/Image/MoriRegionGrow.hxx
new file mode 100644 (file)
index 0000000..29f46ac
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef __fpa__Image__MoriRegionGrow__hxx__
+#define __fpa__Image__MoriRegionGrow__hxx__
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >::
+MoriRegionGrow( )
+  : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >::
+~MoriRegionGrow( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+void fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage >::
+_BeforeGenerateData( )
+{
+  this->Superclass::_BeforeGenerateData( );
+
+  TGrowFunction* grow =
+    dynamic_cast< TGrowFunction* >( this->GetGrowFunction( ) );
+  if( grow != NULL )
+    grow->SetImage( this->GetInput( ) );
+}
+
+#endif // __fpa__Image__MoriRegionGrow__hxx__
+
+// eof - $RCSfile$
index 9655ca36336fd6dc6df09d0143ceb329a5a8b743..9f44dd14d070960f68c63f4396d165df8827d78b 100644 (file)
@@ -4,9 +4,12 @@ tinclude fpa/Image/Functors/SimpleNeighborhood:h|hxx
 instances fpa::Image::Functors::SimpleNeighborhood< itk::Image< #scalar_types#, #pdims# > >
 
 cinclude fpa/Base/RegionGrow.hxx
+cinclude fpa/Base/MoriRegionGrow.hxx
 define all_int_types=#int_types#;#uint_types#
 tinclude fpa/Image/RegionGrow: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::MoriRegionGrow< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
 
 cinclude fpa/Base/Dijkstra.hxx
 tinclude fpa/Image/Dijkstra:h|hxx
diff --git a/plugins/ImageAlgorithms/MoriRegionGrow.cxx b/plugins/ImageAlgorithms/MoriRegionGrow.cxx
new file mode 100644 (file)
index 0000000..c12e855
--- /dev/null
@@ -0,0 +1,74 @@
+#include <ImageAlgorithms/MoriRegionGrow.h>
+#include <cpInstances/DataObjects/Image.h>
+
+#include <fpa/Image/MoriRegionGrow.h>
+
+// -------------------------------------------------------------------------
+fpaPluginsImageAlgorithms::MoriRegionGrow::
+MoriRegionGrow( )
+  : Superclass( )
+{
+  typedef cpPlugins::Pipeline::DataObject _TData;
+
+  this->_ConfigureInput< _TData >( "GrowFunction", true, false );
+  this->m_Parameters.ConfigureAsInt( "InsideValue", 1 );
+  this->m_Parameters.ConfigureAsInt( "OutsideValue", 0 );
+  this->m_Parameters.ConfigureAsInt( "Step", 1 );
+  this->m_Parameters.ConfigureAsReal( "LowerThreshold", 1 );
+  this->m_Parameters.ConfigureAsReal( "UpperThreshold", 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 )
+{
+  typedef
+    itk::Image< _TOutputPixel, _TInputImage::ImageDimension >
+    _TOutputImage;
+  typedef fpa::Image::MoriRegionGrow< _TInputImage, _TOutputImage > _TFilter;
+  typedef typename _TFilter::TGrowFunction                      _TGrow;
+
+  auto filter = this->_CreateITK< _TFilter >( );
+  this->_ConfigureFilter( filter, image );
+  filter->SetGrowFunction( this->GetInputData< _TGrow >( "GrowFunction" ) );
+  filter->SetInsideValue( this->m_Parameters.GetInt( "InsideValue" ) );
+  filter->SetOutsideValue( this->m_Parameters.GetInt( "OutsideValue" ) );
+  filter->Update( );
+  this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/ImageAlgorithms/MoriRegionGrow.h b/plugins/ImageAlgorithms/MoriRegionGrow.h
new file mode 100644 (file)
index 0000000..653bd3d
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef __fpaPluginsImageAlgorithms__MoriRegionGrow__h__
+#define __fpaPluginsImageAlgorithms__MoriRegionGrow__h__
+
+#include <ImageAlgorithms/BaseFilter.h>
+
+namespace fpaPluginsImageAlgorithms
+{
+  /**
+   */
+  class fpaPluginsImageAlgorithms_EXPORT MoriRegionGrow
+    : public BaseFilter
+  {
+    cpPluginsObject( MoriRegionGrow, BaseFilter, 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 9ed2db673500df1c8f59a63c3451f30ae5734aa6..f385e4aa3d4d3a3c62d0ad75519668ed4561f0bd 100644 (file)
@@ -1,7 +1,7 @@
 #include <RegionGrowFunctors/BinaryThreshold.h>
 #include <cpInstances/DataObjects/Image.h>
 
-#include <fpa/Image/Functors/RegionGrowBinaryThreshold.h>
+#include <fpa/Image/Functors/RegionGrow/BinaryThreshold.h>
 #include <itkConstNeighborhoodIterator.h>
 #include <vtkPolyData.h>
 
@@ -18,8 +18,8 @@ BinaryThreshold( )
   this->_ConfigureOutput< _TData >( "Output" );
 
   this->m_Parameters.ConfigureAsUint( "Radius", 1 );
-  this->m_Parameters.ConfigureAsReal( "LowerThreshold", 0 );
-  this->m_Parameters.ConfigureAsReal( "UpperThreshold", 0 );
+  this->m_Parameters.ConfigureAsReal( "Lower", 0 );
+  this->m_Parameters.ConfigureAsReal( "Upper", 0 );
 }
 
 // -------------------------------------------------------------------------
@@ -44,7 +44,7 @@ _GD0( _TImage* image )
 {
   typedef itk::ConstNeighborhoodIterator< _TImage > _TInIt;
   typedef
-    fpa::Image::Functors::RegionGrowBinaryThreshold< _TImage >
+    fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage >
     _TFunctor;
   auto out = this->GetOutput( "Output" );
   auto f = out->GetITK< _TFunctor >( );
@@ -107,15 +107,15 @@ _GD0( _TImage* image )
     s = std::sqrt( s );
     v_min = m - s;
     v_max = m + s;
-    f->SetLowerThreshold( v_min );
-    f->SetUpperThreshold( v_max );
-    this->m_Parameters.SetReal( "LowerThreshold", f->GetLowerThreshold( ) );
-    this->m_Parameters.SetReal( "UpperThreshold", f->GetUpperThreshold( ) );
+    f->SetLower( v_min );
+    f->SetUpper( v_max );
+    this->m_Parameters.SetReal( "Lower", f->GetLower( ) );
+    this->m_Parameters.SetReal( "Upper", f->GetUpper( ) );
   }
   else
   {
-    f->SetLowerThreshold( this->m_Parameters.GetReal( "LowerThreshold" ) );
-    f->SetUpperThreshold( this->m_Parameters.GetReal( "UpperThreshold" ) );
+    f->SetLower( this->m_Parameters.GetReal( "Lower" ) );
+    f->SetUpper( this->m_Parameters.GetReal( "Upper" ) );
 
   } // fi
 }
index c310a007205c2b481d19fc0a01354d0ba2aa1a46..e43240d35c2c6fe6e36974df22b55ad2ef2a5325 100644 (file)
@@ -1,7 +1,7 @@
 header #define ITK_MANUAL_INSTANTIATION
 
 cinclude itkImage.h
-tinclude fpa/Image/Functors/RegionGrowBinaryThreshold:h|hxx
-instances fpa::Image::Functors::RegionGrowBinaryThreshold< itk::Image< #scalar_types#, #pdims# > >
+tinclude fpa/Image/Functors/RegionGrow/BinaryThreshold:h|hxx
+instances fpa::Image::Functors::RegionGrow::BinaryThreshold< itk::Image< #scalar_types#, #pdims# > >
 
 ** eof - $RCSfile$