]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorDuvan Gomez <da.gomez16@uniandes.edu.co>
Tue, 9 May 2017 20:47:50 +0000 (15:47 -0500)
committerDuvan Gomez <da.gomez16@uniandes.edu.co>
Tue, 9 May 2017 20:47:50 +0000 (15:47 -0500)
CMakeLists.txt
examples/CMakeLists.txt
examples/RegionGrow_Mori.cxx
lib/fpa/Base/PriorityQueueAlgorithm.h [new file with mode: 0644]
plugins/ImageAlgorithms/ImageAlgorithms.i [new file with mode: 0644]
plugins/ImageAlgorithms/SkeletonFilter.cxx [new file with mode: 0644]
plugins/ImageAlgorithms/SkeletonFilter.h [new file with mode: 0644]

index 6b7dd54a0e7a3e89eb4446f6407656e4be0a6d4e..b2a6a18e5fb3952074891383ece9abf21f8521a3 100644 (file)
@@ -51,7 +51,7 @@ set(namespace "${PROJECT_NAME}::")
 ## == Build different parts ==
 ## ===========================
 
-subdirs(lib)
+subdirs(examples lib)
 
 ## ===============================
 ## == Global installation rules ==
index 2bed4e539017b74d308ad932155737162d896e3e..4feb556f0db0c20ac5c29385713dcd31e7c34ff3 100644 (file)
@@ -1,6 +1,6 @@
-OPTION(BUILD_EXAMPLES "Build cpPlugins-free examples." OFF)
-IF(BUILD_EXAMPLES)
-  SET(
+option(BUILD_EXAMPLES "Build cpPlugins-free examples." OFF)
+if(BUILD_EXAMPLES)
+  set(
     _examples
     RegionGrow_Tautology
     RegionGrow_BinaryThreshold
@@ -10,18 +10,18 @@ IF(BUILD_EXAMPLES)
     #BronchiiInitialSegmentationWithMori
     #BronchiiInitialSegmentationWithBinaryThresholdRegionGrow
     )
-  OPTION(BUILD_EXAMPLE_SANDBOX "Build sandbox example." OFF)
-  IF(BUILD_EXAMPLE_SANDBOX)
-    LIST(APPEND _examples sandbox)
-  ENDIF(BUILD_EXAMPLE_SANDBOX)
-  INCLUDE_DIRECTORIES(
-    ${PROJECT_SOURCE_DIR}/libs
-    ${PROJECT_BINARY_DIR}/libs
+  option(BUILD_EXAMPLE_SANDBOX "Build sandbox example." OFF)
+  if(BUILD_EXAMPLE_SANDBOX)
+    list(APPEND _examples sandbox)
+  endif(BUILD_EXAMPLE_SANDBOX)
+  include_directories(
+    ${PROJECT_SOURCE_DIR}/lib
+    ${PROJECT_BINARY_DIR}/lib
     )
-  FOREACH(_e ${_examples})
-    ADD_EXECUTABLE(fpa_example_${_e} ${_e}.cxx)
-    TARGET_LINK_LIBRARIES(fpa_example_${_e} ${ITK_LIBRARIES})
-  ENDFOREACH(_e)
-ENDIF(BUILD_EXAMPLES)
+  foreach(_e ${_examples})
+    add_executable(fpa_example_${_e} ${_e}.cxx)
+    target_link_libraries(fpa_example_${_e} ${ITK_LIBRARIES})
+  endforeach(_e)
+endif(BUILD_EXAMPLES)
 
 ## eof - $RCSfile$
index 7677fe5b96f5c2fd0b43ad251d3e990c23d8f15b..bdff6aa6b40d851685cff7bb6e91326da2d80c0e 100644 (file)
@@ -39,11 +39,11 @@ public:
 int main( int argc, char* argv[] )
 {
   // Get arguments
-  if( argc < 7 + VDim )
+  if( argc < 6 + VDim )
   {
     std::cerr
       << "Usage: " << argv[ 0 ]
-      << " input_image output_image auxiliary_image lower upper delta";
+      << " input_image output_image lower upper delta";
     for( unsigned int i = 0; i < VDim; ++i )
       std::cerr << " s_" << i;
     std::cerr << std::endl;
@@ -52,10 +52,9 @@ int main( int argc, char* argv[] )
   } // fi
   std::string input_image_filename = argv[ 1 ];
   std::string output_image_filename = argv[ 2 ];
-  std::string auxiliary_image_filename = argv[ 3 ];
-  TPixel lower = std::atof( argv[ 4 ] );
-  TPixel upper = std::atof( argv[ 5 ] );
-  TPixel delta = std::atof( argv[ 6 ] );
+  TPixel lower = std::atof( argv[ 3 ] );
+  TPixel upper = std::atof( argv[ 4 ] );
+  TPixel delta = std::atof( argv[ 5 ] );
 
   TReader::Pointer reader = TReader::New( );
   reader->SetFileName( input_image_filename );
@@ -75,7 +74,7 @@ int main( int argc, char* argv[] )
   filter->SetThresholdRange( lower, upper, delta );
   TImage::PointType pnt;
   for( int i = 0; i < VDim; ++i )
-    pnt[ i ] = std::atof( argv[ i + 7 ] );
+    pnt[ i ] = std::atof( argv[ i + 6 ] );
 
   TImage::IndexType seed;
   if( !( reader->GetOutput( )->TransformPhysicalPointToIndex( pnt, seed ) ) )
@@ -111,14 +110,9 @@ int main( int argc, char* argv[] )
   TWriter::Pointer writer = TWriter::New( );
   writer->SetInput( threshold->GetOutput( ) );
   writer->SetFileName( output_image_filename );
-
-  TWriter::Pointer aux_writer = TWriter::New( );
-  aux_writer->SetInput( filter->GetOutput( ) );
-  aux_writer->SetFileName( auxiliary_image_filename );
   try
   {
     writer->Update( );
-    aux_writer->Update( );
   }
   catch( std::exception& err )
   {
diff --git a/lib/fpa/Base/PriorityQueueAlgorithm.h b/lib/fpa/Base/PriorityQueueAlgorithm.h
new file mode 100644 (file)
index 0000000..0e79396
--- /dev/null
@@ -0,0 +1,65 @@
+#ifndef __fpa__Base__PriorityQueueAlgorithm__h__
+#define __fpa__Base__PriorityQueueAlgorithm__h__
+
+#include <queue>
+#include <itkObject.h>
+
+namespace fpa
+{
+  namespace Base
+  {
+    /**
+     */
+    template< class _TSuperclass >
+    class PriorityQueueAlgorithm
+      : public _TSuperclass
+    {
+    public:
+      typedef PriorityQueueAlgorithm          Self;
+      typedef _TSuperclass                    Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
+
+    protected:
+      typedef typename Superclass::_TQueueNode _TQueueNode;
+      struct _TQueueNodeCompare
+      {
+        bool operator( )( const _TQueueNode& a, const _TQueueNode& b )
+          {
+            return( b.Result < a.Result );
+          }
+      };
+      typedef std::vector< _TQueueNode > _TQueue;
+
+    public:
+      itkTypeMacro( PriorityQueueAlgorithm, Algorithm );
+
+    protected:
+      PriorityQueueAlgorithm( );
+      virtual ~PriorityQueueAlgorithm( );
+
+      virtual unsigned long _QueueSize( ) const override;
+      virtual void _QueueClear( ) override;
+      virtual void _QueuePush( const _TQueueNode& node ) override;
+      virtual _TQueueNode _QueuePop( ) override;
+
+    private:
+      // Purposely not defined
+      PriorityQueueAlgorithm( const Self& other );
+      Self& operator=( const Self& other );
+
+    protected:
+      _TQueue m_Queue;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Base/PriorityQueueAlgorithm.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Base__PriorityQueueAlgorithm__h__
+
+// eof - $RCSfile$
diff --git a/plugins/ImageAlgorithms/ImageAlgorithms.i b/plugins/ImageAlgorithms/ImageAlgorithms.i
new file mode 100644 (file)
index 0000000..810cc82
--- /dev/null
@@ -0,0 +1,50 @@
+header #define ITK_MANUAL_INSTANTIATION
+
+*tinclude fpa/Image/Functors/SimpleNeighborhood:h|hxx
+*instances fpa::Image::Functors::SimpleNeighborhood< itk::Image< #scalar_types#, #pdims# > >
+
+*cinclude fpa/Base/RegionGrow.hxx
+*define all_int_types=#int_types#;#uint_types#
+*tinclude fpa/Image/RegionGrow:h|hxx
+*tinclude fpa/Image/MoriRegionGrowHelper:h|hxx
+*tinclude fpa/Image/MoriRegionGrow:h|hxx
+*instances fpa::Image::RegionGrow< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
+*instances fpa::Image::MoriRegionGrowHelper< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
+*instances fpa::Image::MoriRegionGrow< itk::Image< #scalar_types#, #pdims# >, itk::Image< #all_int_types#, #pdims# > >
+
+*cinclude fpa/Base/Dijkstra.hxx
+*tinclude fpa/Image/Dijkstra:h|hxx
+*instances fpa::Image::Dijkstra< itk::Image< #scalar_types#, #pdims# >, itk::Image< #real_types#, #pdims# > >
+
+tinclude fpa/Image/SkeletonFilter:h|hxx
+instances fpa::Image::SkeletonFilter< itk::Image< #real_types#, #pdims# > >
+
+
+
+*define i_real=#real_types#
+*define o_real=#real_types#
+
+*tinclude fpa/Image/Functors/SimpleDijkstraCost:h|hxx
+*tinclude fpa/Base/Functors/Inverse:h|hxx
+*tinclude fpa/Base/Functors/GaussianModel: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/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$
diff --git a/plugins/ImageAlgorithms/SkeletonFilter.cxx b/plugins/ImageAlgorithms/SkeletonFilter.cxx
new file mode 100644 (file)
index 0000000..274dc65
--- /dev/null
@@ -0,0 +1,82 @@
+#include "SkeletonFilter.h"
+#include <cpInstances/DataObjects/Image.h>
+#include <cpInstances/DataObjects/Skeleton.h>
+
+// -------------------------------------------------------------------------
+fpaPlugins_ImageAlgorithms::SkeletonFilter::
+SkeletonFilter( )
+  : Superclass( )
+{
+  typedef cpPlugins::Pipeline::DataObject    _TData;
+  typedef cpInstances::DataObjects::Image    _TImage;
+  typedef cpInstances::DataObjects::Skeleton _TSkeleton;
+
+  this->_ConfigureInput< _TImage >( "Input", true, false );
+  this->_ConfigureInput< _TData >( "Seeds", true, false );
+  this->_ConfigureOutput< _TSkeleton >( "Output" );
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins_ImageAlgorithms::SkeletonFilter::
+~SkeletonFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+void fpaPlugins_ImageAlgorithms::SkeletonFilter::
+_GenerateData( )
+{
+  /* TODO
+     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 _TImage >
+void fpaPlugins_ImageAlgorithms::SkeletonFilter::
+_GD0( _TImage* image )
+{
+  /* TODO
+     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/SkeletonFilter.h b/plugins/ImageAlgorithms/SkeletonFilter.h
new file mode 100644 (file)
index 0000000..3ebce45
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef __fpaPlugins_ImageAlgorithms__SkeletonFilter__h__
+#define __fpaPlugins_ImageAlgorithms__SkeletonFilter__h__
+
+#include <fpaPlugins_ImageAlgorithms_Export.h>
+#include <cpPlugins/Pipeline/ProcessObject.h>
+
+namespace fpaPlugins_ImageAlgorithms
+{
+  /**
+   */
+  class fpaPlugins_ImageAlgorithms_EXPORT SkeletonFilter
+    : public cpPlugins::Pipeline::ProcessObject
+  {
+    cpPluginsObject(
+      SkeletonFilter,
+      cpPlugins::Pipeline::ProcessObject,
+      fpaImageAlgorithms
+      );
+
+  protected:
+    template< class _TImage >
+    inline void _GD0( _TImage* image );
+  };
+
+} // ecapseman
+
+#endif // __fpaPlugins_ImageAlgorithms__SkeletonFilter__h__
+
+// eof - $RCSfile$