]> Creatis software - FrontAlgorithms.git/commitdiff
Plugins updated
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 18 Jan 2016 23:05:24 +0000 (18:05 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 18 Jan 2016 23:05:24 +0000 (18:05 -0500)
12 files changed:
appli/CMakeLists.txt
lib/fpa/Image/Functors/RegionGrowThresholdFunction.h
lib/fpaPlugins/AllPixelsImageGrowFunctionSource.cxx [new file with mode: 0644]
lib/fpaPlugins/AllPixelsImageGrowFunctionSource.h [new file with mode: 0644]
lib/fpaPlugins/CMakeLists.txt
lib/fpaPlugins/GrowFunction.cxx [new file with mode: 0644]
lib/fpaPlugins/GrowFunction.h [new file with mode: 0644]
lib/fpaPlugins/GrowFunction.hxx [new file with mode: 0644]
lib/fpaPlugins/ImageRegionGrow.cxx
lib/fpaPlugins/ImageRegionGrow.h
lib/fpaPlugins/ThresholdImageGrowFunctionSource.cxx [new file with mode: 0644]
lib/fpaPlugins/ThresholdImageGrowFunctionSource.h [new file with mode: 0644]

index 61d2cd0328ceeecb594c40e83e1d405a4e6b0c83..6d67748de1731258f04adda36a3a534e1e484bda 100644 (file)
@@ -1,6 +1,7 @@
 IF(BUILD_EXAMPLES)
   SUBDIRS(
     examples
+    ## fpaLab
     )
 ENDIF(BUILD_EXAMPLES)
 
index 1ac7c8f080c3acfc155f390a35f2d75720011945..f43ad2c453ceabaad18e9cc9cff7314b6531a3d2 100644 (file)
@@ -58,10 +58,11 @@ namespace fpa
 
       protected:
         RegionGrowThresholdFunction( )
-          : Superclass( ),
-            m_LowerThreshold( itk::NumericTraits< TPixel >::min( ) ),
-            m_UpperThreshold( itk::NumericTraits< TPixel >::max( ) )
-          { }
+          : Superclass( )
+          {
+            itk::NumericTraits< TPixel >::min( this->m_LowerThreshold );
+            itk::NumericTraits< TPixel >::max( this->m_UpperThreshold );
+          }
         virtual ~RegionGrowThresholdFunction( )
           { }
 
diff --git a/lib/fpaPlugins/AllPixelsImageGrowFunctionSource.cxx b/lib/fpaPlugins/AllPixelsImageGrowFunctionSource.cxx
new file mode 100644 (file)
index 0000000..f70ee79
--- /dev/null
@@ -0,0 +1,60 @@
+#include "AllPixelsImageGrowFunctionSource.h"
+
+#include <cpPlugins/Interface/BaseProcessObjects.h>
+#include <cpPlugins/Interface/Image.h>
+#include <fpaPlugins/GrowFunction.h>
+#include <fpa/Image/Functors/RegionGrowAllBelongsFunction.h>
+
+// -------------------------------------------------------------------------
+fpaPlugins::AllPixelsImageGrowFunctionSource::
+AllPixelsImageGrowFunctionSource( )
+  : Superclass( )
+{
+  this->_AddInput( "ReferenceImage" );
+  this->_MakeOutput< GrowFunction >( "Output" );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins::AllPixelsImageGrowFunctionSource::
+~AllPixelsImageGrowFunctionSource( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string fpaPlugins::AllPixelsImageGrowFunctionSource::
+_GenerateData( )
+{
+  cpPlugins::Interface::Image* image =
+    this->GetInput< cpPlugins::Interface::Image >( "ReferenceImage" );
+  if( image == NULL )
+    return( "fpaPlugins::AllPixelsImageGrowFunctionSource: No input reference image." );
+
+  itk::DataObject* itk_image = NULL;
+  std::string r = "";
+  cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
+  else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 );
+  else r = "fpaPlugins::AllPixelsImageGrowFunctionSource: no valid reference image.";
+
+  return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+std::string fpaPlugins::AllPixelsImageGrowFunctionSource::
+_GD0( itk::DataObject* data )
+{
+  typedef fpa::Image::Functors::RegionGrowAllBelongsFunction< I > _F;
+  typename _F::Pointer functor = _F::New( );
+
+  // Connect output
+  GrowFunction* out = this->GetOutput< GrowFunction >( "Output" );
+  if( out != NULL )
+  {
+    out->SetITK< _F >( functor );
+    return( "" );
+  }
+  else
+    return( "fpaPlugins::AllPixelsImageGrowFunctionSource: output not correctly created." );
+}
+
+// eof - $RCSfile$
diff --git a/lib/fpaPlugins/AllPixelsImageGrowFunctionSource.h b/lib/fpaPlugins/AllPixelsImageGrowFunctionSource.h
new file mode 100644 (file)
index 0000000..51761a2
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef __FPAPLUGINS__ALLPIXELSIMAGEGROWFUNCTIONSOURCE__H__
+#define __FPAPLUGINS__ALLPIXELSIMAGEGROWFUNCTIONSOURCE__H__
+
+#include <fpaPlugins/fpaPlugins_Export.h>
+#include <cpPlugins/Interface/ProcessObject.h>
+
+namespace fpaPlugins
+{
+  /**
+   */
+  class fpaPlugins_EXPORT AllPixelsImageGrowFunctionSource
+    : public cpPlugins::Interface::ProcessObject
+  {
+  public:
+    typedef AllPixelsImageGrowFunctionSource    Self;
+    typedef cpPlugins::Interface::ProcessObject Superclass;
+    typedef itk::SmartPointer< Self >           Pointer;
+    typedef itk::SmartPointer< const Self >     ConstPointer;
+
+  public:
+    itkNewMacro( Self );
+    itkTypeMacro(
+      AllPixelsImageGrowFunctionSource, cpPlugins::Interface::ProcessObject
+      );
+    cpPlugins_Id_Macro(
+      AllPixelsImageGrowFunctionSource, FrontPropagationFunctors
+      );
+
+  protected:
+    AllPixelsImageGrowFunctionSource( );
+    virtual ~AllPixelsImageGrowFunctionSource( );
+
+    virtual std::string _GenerateData( );
+
+    template< class I >
+      std::string _GD0( itk::DataObject* data );
+
+  private:
+    // Purposely not implemented.
+    AllPixelsImageGrowFunctionSource( const Self& other );
+    Self& operator=( const Self& other );
+  };
+
+  // ---------------------------------------------------------------------
+  CPPLUGINS_INHERIT_PROVIDER( AllPixelsImageGrowFunctionSource );
+
+} // ecapseman
+
+#endif // __FPAPLUGINS__ALLPIXELSIMAGEGROWFUNCTIONSOURCE__H__
+
+// eof - $RCSfile$
index ec3c96dcc1f41f424848308867ea8ad6515819c8..4b9bf2ee1a01d877745f6e74dc877795691b6c93 100644 (file)
@@ -4,12 +4,31 @@ SET(LIBRARY_NAME fpaPlugins)
 ## = Source code =
 ## ===============
 
-FILE(GLOB LIB_HEADERS_H   "*.h")
-FILE(GLOB LIB_HEADERS_HPP "*.hpp")
-FILE(GLOB LIB_HEADERS_HXX "*.hxx")
-FILE(GLOB LIB_SOURCES_C   "*.c")
-FILE(GLOB LIB_SOURCES_CPP "*.cpp")
-FILE(GLOB LIB_SOURCES_CXX "*.cxx")
+SET(
+  data_LIB_HEADERS
+  GrowFunction.h
+  GrowFunction.hxx
+  )
+SET(
+  filters_LIB_HEADERS
+  AllPixelsImageGrowFunctionSource.h
+  ThresholdImageGrowFunctionSource.h
+  ImageRegionGrow.h
+  )
+SET(
+  data_LIB_SOURCES
+  GrowFunction.cxx
+  )
+SET(
+  filters_LIB_SOURCES
+  AllPixelsImageGrowFunctionSource.cxx
+  ThresholdImageGrowFunctionSource.cxx
+  ImageRegionGrow.cxx
+  )
+INCLUDE_DIRECTORIES(
+  ${PROJECT_SOURCE_DIR}/lib/fpaPlugins
+  ${PROJECT_BINARY_DIR}/lib/fpaPlugins
+  )
 
 ## =====================
 ## = Compilation rules =
@@ -17,17 +36,16 @@ FILE(GLOB LIB_SOURCES_CXX "*.cxx")
 
 ADD_CUSTOM_COMMAND(
   OUTPUT ${LIBRARY_NAME}_Host.cxx
-  DEPENDS ${cpPlugins_createHost_APP} ${LIB_HEADERS_H}
-  COMMAND ${cpPlugins_createHost_APP} ${LIBRARY_NAME}_Host.cxx fpaPlugins ${LIB_HEADERS_H}
+  DEPENDS ${cpPlugins_createHost_APP} ${filters_LIB_HEADERS}
+  COMMAND ${cpPlugins_createHost_APP} ${LIBRARY_NAME}_Host.cxx fpaPlugins ${filters_LIB_HEADERS}
   )
 
 ADD_LIBRARY(
   ${LIBRARY_NAME}
   SHARED
   ${LIBRARY_NAME}_Host.cxx
-  ${LIB_SOURCES_C}
-  ${LIB_SOURCES_CPP}
-  ${LIB_SOURCES_CXX}
+  ${data_LIB_SOURCES}
+  ${filters_LIB_SOURCES}
   )
 GENERATE_EXPORT_HEADER(
   ${LIBRARY_NAME}
diff --git a/lib/fpaPlugins/GrowFunction.cxx b/lib/fpaPlugins/GrowFunction.cxx
new file mode 100644 (file)
index 0000000..9b6d0d9
--- /dev/null
@@ -0,0 +1,16 @@
+#include <fpaPlugins/GrowFunction.h>
+
+// -------------------------------------------------------------------------
+fpaPlugins::GrowFunction::
+GrowFunction( )
+  : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins::GrowFunction::
+~GrowFunction( )
+{
+}
+
+// eof - $RCSfile$
diff --git a/lib/fpaPlugins/GrowFunction.h b/lib/fpaPlugins/GrowFunction.h
new file mode 100644 (file)
index 0000000..696e5b6
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef __FPAPLUGINS__GROWFUNCTION__H__
+#define __FPAPLUGINS__GROWFUNCTION__H__
+
+#include <cpPlugins/Interface/DataObject.h>
+
+#include <itkProcessObject.h>
+
+// -------------------------------------------------------------------------
+namespace fpaPlugins
+{
+  /**
+   */
+  class cpPlugins_Interface_EXPORT GrowFunction
+    : public cpPlugins::Interface::DataObject
+  {
+  public:
+    typedef GrowFunction                     Self;
+    typedef cpPlugins::Interface::DataObject Superclass;
+    typedef itk::SmartPointer< Self >        Pointer;
+    typedef itk::SmartPointer< const Self >  ConstPointer;
+
+  public:
+    itkNewMacro( Self );
+    itkTypeMacro( GrowFunction, cpPlugins::Interface::DataObject );
+    cpPlugins_Id_Macro( GrowFunction, GrowFunction );
+
+  public:
+    template< class F >
+      inline void SetITK( itk::Object* object );
+
+  protected:
+    GrowFunction( );
+    virtual ~GrowFunction( );
+
+  private:
+    // Purposely not implemented
+    GrowFunction( const Self& );
+    Self& operator=( const Self& );
+  };
+
+} // ecapseman
+
+#include <fpaPlugins/GrowFunction.hxx>
+
+#endif // __FPAPLUGINS__GROWFUNCTION__H__
+
+// eof - $RCSfile$
diff --git a/lib/fpaPlugins/GrowFunction.hxx b/lib/fpaPlugins/GrowFunction.hxx
new file mode 100644 (file)
index 0000000..00c2cba
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef __FPAPLUGINS__GROWFUNCTION__HXX__
+#define __FPAPLUGINS__GROWFUNCTION__HXX__
+
+#include <itkFunctionBase.h>
+
+// -------------------------------------------------------------------------
+template< class F >
+void fpaPlugins::GrowFunction::
+SetITK( itk::Object* object )
+{
+  typedef typename F::TSpace                  _TSpace;
+  typedef typename F::TVertex                 _TVertex;
+  typedef itk::FunctionBase< _TVertex, bool > _TBaseFunction;
+
+  _TBaseFunction* function = dynamic_cast< _TBaseFunction* >( object );
+  if( function != NULL )
+  {
+    this->m_ITKObject = function;
+    this->m_VTKObject = NULL;
+    this->Modified( );
+
+  } // fi
+}
+
+#endif // __FPAPLUGINS__GROWFUNCTION__HXX__
+
+// eof - $RCSfile$
index 642976524b594e46013375b9ad77d5dc89b968d6..86c67e748480012ab377284e6248b6af573c03d6 100644 (file)
@@ -13,12 +13,17 @@ ImageRegionGrow( )
   this->_AddInput( "GrowFunction" );
   this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
 
-  this->m_Parameters->ConfigureAsBool( "VisualDebug", false );
-  this->m_Parameters->ConfigureAsBool( "StopAtOneFront", false );
-  this->m_Parameters->ConfigureAsReal( "InsideValue", 1 );
-  this->m_Parameters->ConfigureAsReal( "OutsideValue", 0 );
+  this->m_Parameters->ConfigureAsBool( "VisualDebug" );
+  this->m_Parameters->ConfigureAsBool( "StopAtOneFront" );
+  this->m_Parameters->ConfigureAsReal( "InsideValue" );
+  this->m_Parameters->ConfigureAsReal( "OutsideValue" );
   this->m_Parameters->ConfigureAsPointList( "Seeds" );
 
+  this->m_Parameters->SetBool( "VisualDebug", false );
+  this->m_Parameters->SetBool( "StopAtOneFront", false );
+  this->m_Parameters->SetReal( "InsideValue", 1 );
+  this->m_Parameters->SetReal( "OutsideValue", 0 );
+
   std::vector< std::string > orders;
   orders.push_back( "1" );
   orders.push_back( "2" );
@@ -57,6 +62,7 @@ _GD0( itk::DataObject* data )
   typedef itk::Image< _TOutPixel, I::ImageDimension > _TOut;
   typedef fpa::Image::RegionGrow< I, _TOut >          _TFilter;
   typedef typename _TFilter::TGrowingFunction         _TFunctor;
+  typedef typename I::PointType                       _TPoint;
 
   I* image = dynamic_cast< I* >( data );
 
@@ -83,8 +89,8 @@ _GD0( itk::DataObject* data )
   filter->SetOutsideValue( _TOutPixel( params->GetReal( "OutsideValue" ) ) );
 
   // Assign seeds
-  std::vector< typename I::PointType > seeds;
-  params->GetPointList( seeds, "Seeds", I::ImageDimension );
+  std::vector< _TPoint > seeds =
+    params->GetPointList< _TPoint >( "Seeds", I::ImageDimension );
   for( auto sIt = seeds.begin( ); sIt != seeds.end( ); ++sIt )
   {
     typename I::IndexType idx;
index e653755e39a6aa52b579c84511ae38e8baace05b..f6ce3ffb4eb3b3315072e3d6f58e30590b5bd139 100644 (file)
@@ -23,7 +23,7 @@ namespace fpaPlugins
       ImageRegionGrow, cpPlugins::Interface::ImageToImageFilter
       );
     cpPlugins_Id_Macro(
-      fpaPlugins::ImageRegionGrow, "FrontPropagationImageAlgorithms"
+      ImageRegionGrow, FrontPropagationImageAlgorithm
       );
 
   protected:
diff --git a/lib/fpaPlugins/ThresholdImageGrowFunctionSource.cxx b/lib/fpaPlugins/ThresholdImageGrowFunctionSource.cxx
new file mode 100644 (file)
index 0000000..8ea176e
--- /dev/null
@@ -0,0 +1,66 @@
+#include "ThresholdImageGrowFunctionSource.h"
+
+#include <cpPlugins/Interface/BaseProcessObjects.h>
+#include <cpPlugins/Interface/Image.h>
+#include <fpaPlugins/GrowFunction.h>
+#include <fpa/Image/Functors/RegionGrowThresholdFunction.h>
+
+// -------------------------------------------------------------------------
+fpaPlugins::ThresholdImageGrowFunctionSource::
+ThresholdImageGrowFunctionSource( )
+  : Superclass( )
+{
+  this->_AddInput( "ReferenceImage" );
+  this->_MakeOutput< GrowFunction >( "Output" );
+
+  this->m_Parameters->ConfigureAsReal( "LowerThreshold" );
+  this->m_Parameters->ConfigureAsReal( "UpperThreshold" );
+
+  this->m_Parameters->SetReal( "LowerThreshold", 0 );
+  this->m_Parameters->SetReal( "UpperThreshold", 0 );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins::ThresholdImageGrowFunctionSource::
+~ThresholdImageGrowFunctionSource( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string fpaPlugins::ThresholdImageGrowFunctionSource::
+_GenerateData( )
+{
+  cpPlugins::Interface::Image* image =
+    this->GetInput< cpPlugins::Interface::Image >( "ReferenceImage" );
+  if( image == NULL )
+    return( "fpaPlugins::ThresholdImageGrowFunctionSource: No input reference image." );
+
+  itk::DataObject* itk_image = NULL;
+  std::string r = "";
+  cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
+  else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 );
+  else r = "fpaPlugins::ThresholdImageGrowFunctionSource: no valid reference image.";
+
+  return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+std::string fpaPlugins::ThresholdImageGrowFunctionSource::
+_GD0( itk::DataObject* data )
+{
+  typedef fpa::Image::Functors::RegionGrowThresholdFunction< I > _F;
+  typename _F::Pointer functor = _F::New( );
+
+  // Connect output
+  GrowFunction* out = this->GetOutput< GrowFunction >( "Output" );
+  if( out != NULL )
+  {
+    out->SetITK< _F >( functor );
+    return( "" );
+  }
+  else
+    return( "fpaPlugins::ThresholdImageGrowFunctionSource: output not correctly created." );
+}
+
+// eof - $RCSfile$
diff --git a/lib/fpaPlugins/ThresholdImageGrowFunctionSource.h b/lib/fpaPlugins/ThresholdImageGrowFunctionSource.h
new file mode 100644 (file)
index 0000000..acd978b
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef __FPAPLUGINS__THRESHOLDIMAGEGROWFUNCTIONSOURCE__H__
+#define __FPAPLUGINS__THRESHOLDIMAGEGROWFUNCTIONSOURCE__H__
+
+#include <fpaPlugins/fpaPlugins_Export.h>
+#include <cpPlugins/Interface/ProcessObject.h>
+
+namespace fpaPlugins
+{
+  /**
+   */
+  class fpaPlugins_EXPORT ThresholdImageGrowFunctionSource
+    : public cpPlugins::Interface::ProcessObject
+  {
+  public:
+    typedef ThresholdImageGrowFunctionSource    Self;
+    typedef cpPlugins::Interface::ProcessObject Superclass;
+    typedef itk::SmartPointer< Self >           Pointer;
+    typedef itk::SmartPointer< const Self >     ConstPointer;
+
+  public:
+    itkNewMacro( Self );
+    itkTypeMacro(
+      ThresholdImageGrowFunctionSource, cpPlugins::Interface::ProcessObject
+      );
+    cpPlugins_Id_Macro(
+      ThresholdImageGrowFunctionSource, FrontPropagationFunctors
+      );
+
+  protected:
+    ThresholdImageGrowFunctionSource( );
+    virtual ~ThresholdImageGrowFunctionSource( );
+
+    virtual std::string _GenerateData( );
+
+    template< class I >
+      std::string _GD0( itk::DataObject* data );
+
+  private:
+    // Purposely not implemented.
+    ThresholdImageGrowFunctionSource( const Self& other );
+    Self& operator=( const Self& other );
+  };
+
+  // ---------------------------------------------------------------------
+  CPPLUGINS_INHERIT_PROVIDER( ThresholdImageGrowFunctionSource );
+
+} // ecapseman
+
+#endif // __FPAPLUGINS__THRESHOLDIMAGEGROWFUNCTIONSOURCE__H__
+
+// eof - $RCSfile$