]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 22 Apr 2016 23:03:11 +0000 (18:03 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 22 Apr 2016 23:03:11 +0000 (18:03 -0500)
plugins/fpa/BaseImageFilter.hxx
plugins/fpa/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.cxx
plugins/fpa/ExtractPathFromMinimumSpanningTree.cxx
plugins/fpa/GradientBaseImageFunctionSource.cxx
plugins/fpa/ImageDijkstra.cxx
plugins/fpa/ImageDijkstra.h
plugins/fpa/ImageRegionGrow.cxx
plugins/fpa/InvertCostFunction.cxx
plugins/fpa/MinimumSpanningTreeReader.cxx
plugins/fpa/MinimumSpanningTreeWriter.cxx
plugins/fpa/RegionGrowThresholdFunction.cxx

index 6bce1d5540c0900fbd2778b23b91e9f5ba05181b..b8e02695f40cf5c73d2da28f167d9e9cb875c2a5 100644 (file)
@@ -11,14 +11,11 @@ _ConfigureFilter( )
 {
   typedef typename _TFilter::TInputImage _TImage;
   static const unsigned int Dim = _TImage::ImageDimension;
-  typedef
-    cpExtensions::DataStructures::ImageIndexesContainer< Dim >
-    _TIndexes;
 
-  auto image = this->GetInputData( "Input" )->GetITK< _TImage >( );
+  auto image = this->GetInputData< _TImage >( "Input" );
   if( image == NULL )
     return( NULL );
-  auto indexes = this->GetInputData( "Seeds" )->GetITK< _TIndexes >( );
+  auto seeds = this->GetInputData< vtkPoints >( "Seeds" );
 
   // Create filter and connect input
   auto filter = this->_CreateITK< _TFilter >( );
@@ -32,11 +29,24 @@ _ConfigureFilter( )
 
   // Assign seeds
   filter->ClearSeeds( );
-  if( indexes != NULL )
+  if( seeds != NULL )
   {
-    auto iIt = indexes->Get( ).begin( );
-    for( ; iIt != indexes->Get( ).end( ); ++iIt )
-      filter->AddSeed( *iIt, 0 );
+    typename _TImage::PointType pnt;
+    typename _TImage::IndexType idx;
+    unsigned int dim =
+      ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3;
+    for( unsigned 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
 
@@ -50,13 +60,12 @@ void fpaPlugins::BaseImageFilter::
 _ExecuteFilter( _TFilter* filter )
 {
   // Go!!!
-  this->_ConfigureDebugger( filter );
+  // this->_ConfigureDebugger( filter );
   filter->Update( );
-  this->_DeconfigureDebugger( filter );
+  // this->_DeconfigureDebugger( filter );
 
   // Connect output
-  auto out = this->GetOutputData( "Output" );
-  out->SetITK( filter->GetOutput( ) );
+  this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
 }
 
 // -------------------------------------------------------------------------
index 73fbad0c95e7e2c05508bfde2e6f521dd15f9119..ea2c37abfeb6cd77b9fc72216658165817bfe5f5 100644 (file)
@@ -32,7 +32,7 @@ fpaPlugins::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree::
 void fpaPlugins::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree::
 _GenerateData( )
 {
-  auto image = this->GetInputData( "CostsImage" )->GetITK< itk::DataObject >( );
+  auto image = this->GetInputData< itk::DataObject >( "CostsImage" );
   cpPlugins_Image_Demangle_Pixel_AllFloats     ( _GD0, image, 2 );
   else cpPlugins_Image_Demangle_Pixel_AllFloats( _GD0, image, 3 );
   else this->_Error( "Invalid input costs." );
@@ -47,10 +47,10 @@ _GD0( _TImage* image )
   typedef fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST > _TFilter;
 
   // Check input objects' integrity
-  auto dmap = this->GetInputData( "DistanceMap" )->GetITK< _TImage >( );
+  auto dmap = this->GetInputData< _TImage >( "DistanceMap" );
   if( dmap == NULL )
     this->_Error( "Distance map does not have the same type as the costs image." );
-  auto mst = this->GetInputData( "MST" )->GetITK< _TMST >( );
+  auto mst = this->GetInputData< _TMST >( "MST" );
   if( mst == NULL )
     this->_Error( "No valid input tree." );
 
@@ -64,10 +64,10 @@ _GD0( _TImage* image )
     );
   filter->Update( );
 
-  this->GetOutputData( "EndPoints" )->SetITK( filter->GetEndPoints( ) );
-  this->GetOutputData( "Bifurcations" )->SetITK( filter->GetBifurcations( ) );
-  this->GetOutputData( "Collisions" )->SetITK( filter->GetCollisions( ) );
-  this->GetOutputData( "Skeleton" )->SetITK( filter->GetSkeleton( ) );
+  this->GetOutput( "EndPoints" )->SetITK( filter->GetEndPoints( ) );
+  this->GetOutput( "Bifurcations" )->SetITK( filter->GetBifurcations( ) );
+  this->GetOutput( "Collisions" )->SetITK( filter->GetCollisions( ) );
+  this->GetOutput( "Skeleton" )->SetITK( filter->GetSkeleton( ) );
 }
 
 // eof - $RCSfile$
index 7e41b4f6dc337bd7d20295c40ac4c2ea94668556..0f717abc9e932917458844d187c55b43ffd80226 100644 (file)
@@ -31,7 +31,7 @@ _GenerateData( )
   typedef fpa::Image::MinimumSpanningTree< 2 > _2DMST;
   typedef fpa::Image::MinimumSpanningTree< 3 > _3DMST;
 
-  auto mst = this->GetInputData( "MST" )->GetITK< itk::DataObject >( );
+  auto mst = this->GetInputData< itk::DataObject >( "MST" );
   auto mst2 = dynamic_cast< _2DMST* >( mst );
   auto mst3 = dynamic_cast< _3DMST* >( mst );
   if     ( mst2 != NULL ) this->_GD0( mst2 );
@@ -45,16 +45,27 @@ void fpaPlugins::ExtractPathFromMinimumSpanningTree::
 _GD0( _TMST* mst )
 {
   typedef fpa::Base::ExtractPathFromMinimumSpanningTree< _TMST > _TFilter;
-  typedef
-    cpExtensions::DataStructures::ImageIndexesContainer< _TMST::Dimension >
-    _TVertices;
-  auto vertices = this->GetInputData( "Seeds" )->GetITK< _TVertices >( );
+  auto vertices = this->GetInputData< vtkPoints >( "Seeds" );
   if( vertices == NULL )
     this->_Error( "No valid vertices." );
-  if( vertices->Get( ).size( ) < 2 )
+  if( vertices->GetNumberOfPoints( ) < 2 )
     this->_Error( "Not enough vertices." );
-  auto v0 = vertices->Get( )[ this->m_Parameters.GetUint( "Vertex0" ) ];
-  auto v1 = vertices->Get( )[ this->m_Parameters.GetUint( "Vertex1" ) ];
+
+  double b0[ 3 ], b1[ 3 ];
+  vertices->GetPoint( this->m_Parameters.GetUint( "Vertex0" ), b0 );
+  vertices->GetPoint( this->m_Parameters.GetUint( "Vertex1" ), b1 );
+
+  typename _TMST::PointType p0, p1;
+  unsigned int dim = ( _TMST::ImageDimension < 3 )? _TMST::ImageDimension: 3;
+  for( unsigned int d = 0; d < dim; ++d )
+  {
+    p0[ d ] = b0[ d ];
+    p1[ d ] = b1[ d ];
+
+  } // rof
+  typename _TMST::TVertex v0, v1;
+  mst->TransformPhysicalPointToIndex( p0, v0 );
+  mst->TransformPhysicalPointToIndex( p1, v1 );
 
   // Create filter and connect input
   _TFilter* filter = this->_CreateITK< _TFilter >( );
@@ -64,7 +75,7 @@ _GD0( _TMST* mst )
   filter->Update( );
 
   // Connect output and finish
-  this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
+  this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
 }
 
 // eof - $RCSfile$
index df069d3cfea9a9671b3174820e24d4b5e3e0e693..85a79ce168a59485b7f4579532485514546f2433 100644 (file)
@@ -38,7 +38,7 @@ fpaPlugins::GradientBaseImageFunctionSource::
 void fpaPlugins::GradientBaseImageFunctionSource::
 _GenerateData( )
 {
-  auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
+  auto image = this->GetInputData< itk::DataObject >( "Input" );
   cpPlugins_Image_Demangle_VectorPixel_AllFloats     ( _GD0, image, CovariantVector, 2 );
   else cpPlugins_Image_Demangle_VectorPixel_AllFloats( _GD0, image, CovariantVector, 3 );
   else this->_Error( "Invalid input image." );
@@ -87,7 +87,7 @@ _GD1( _TImage* image )
   filter->Update( );
 
   // Connect output and finish
-  this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
+  this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
 }
 
 // eof - $RCSfile$
index b45999d57351897c456bf0f5b40ac297c7e064c4..d2fae9a97f94a76115e608f07dde9be379ab0f98 100644 (file)
@@ -25,7 +25,7 @@ fpaPlugins::ImageDijkstra::
 void fpaPlugins::ImageDijkstra::
 _GenerateData( )
 {
-  auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
+  auto image = this->GetInputData< itk::DataObject >( "Input" );
   cpPlugins_Image_Demangle_Pixel_AllScalars     ( _GD0, image, 2 );
   else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 );
   else this->_Error( "No valid input image." );
@@ -44,7 +44,7 @@ _GD0( _TImage* image )
   typedef typename _TFilter::TMinimumSpanningTree        _TMST;
 
   auto base_functor =
-    this->GetInputData( "CostFunctor" )->GetITK< itk::LightObject >( );
+    this->GetInputData< itk::LightObject >( "CostFunctor" );
   _TCostFunctor* functor = NULL;
   if( base_functor != NULL )
   {
@@ -63,8 +63,10 @@ _GD0( _TImage* image )
   this->_ExecuteFilter( filter );
 
   // Connect remaining output
-  this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
-  this->GetOutputData( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) );
+  this->GetOutput( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) );
+
+  std::cout << "Internal: " << filter->GetMTime( ) << std::endl;
+
 }
 
 // eof - $RCSfile$
index e4cb3de5f651235a86ff2b028fd061a1dcd42c67..efc86fb0da9977873ae5f55448b68bd6897e8185 100644 (file)
@@ -21,6 +21,14 @@ namespace fpaPlugins
     itkTypeMacro( ImageDijkstra, BaseImageFilter );
     cpPlugins_Id_Macro( ImageDijkstra, fpaImageAlgorithm );
 
+    virtual itk::ModifiedTimeType GetMTime( ) const
+    {
+      auto t = this->Superclass::GetMTime( );
+      std::cout << "Dijkstra time: " << t << std::endl;
+      return( t );
+    }
+
+
   protected:
     ImageDijkstra( );
     virtual ~ImageDijkstra( );
index 16a47e85953cfa3f32b3cb8c967ec9dfa526a7cc..333c70865afbf8ce0f49b43263112a3649dbac7e 100644 (file)
@@ -25,7 +25,7 @@ fpaPlugins::ImageRegionGrow::
 void fpaPlugins::ImageRegionGrow::
 _GenerateData( )
 {
-  auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
+  auto image = this->GetInputData< itk::DataObject >( "Input" );
   cpPlugins_Image_Demangle_Pixel_AllScalars     ( _GD0, image, 2 );
   else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 );
   else this->_Error( "No valid input image." );
@@ -46,7 +46,7 @@ _GD0( _TImage* image )
   _TFilter* filter = this->_ConfigureFilter< _TFilter >( );
 
   typename _TGrowFunctor::Pointer functor;
-  auto wrap_functor = this->GetInputData( "GrowFunctor" );
+  auto wrap_functor = this->GetInput( "GrowFunctor" );
   if( wrap_functor != NULL )
     functor = wrap_functor->GetITK< _TGrowFunctor >( );
   if( functor.IsNull( ) )
@@ -60,9 +60,6 @@ _GD0( _TImage* image )
 
   // Go!!!
   this->_ExecuteFilter( filter );
-
-  // Connect remaining output
-  this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
 }
 
 // eof - $RCSfile$
index abd4f1ecf49d43de94fc6aa3472f075599e026ed..3664bfa64689fa10f7210eca0b38714c6b09a154 100644 (file)
@@ -45,7 +45,7 @@ void fpaPlugins::InvertCostFunction::
 _GD0( )
 {
   typedef fpa::Base::Functors::InvertCostFunction< _TScalar > _TFunctor;
-  auto out = this->GetOutputData( "Output" );
+  auto out = this->GetOutput( "Output" );
   auto f = out->GetITK< _TFunctor >( );
   if( f == NULL )
   {
index 16f421e4e3b53c16b80bfdde46942c312c9e0403..e0c4ffe9b1f86d82f13276e4efb2e5cc4b044631 100644 (file)
@@ -64,7 +64,7 @@ _GD0( const std::string& fname )
     this->_Error( err.GetDescription( ) );
 
   } // yrt
-  this->GetOutputData( "Output" )->SetITK( reader->GetOutput( ) );
+  this->GetOutput( "Output" )->SetITK( reader->GetOutput( ) );
 }
 
 // eof - $RCSfile$
index d0f35598b07966a50b2092c15b165fc90015e685..991090812bf6bdfe790feb1337aeb7da5cf39960 100644 (file)
@@ -30,8 +30,8 @@ _GenerateData( )
   typedef fpa::Image::MinimumSpanningTree< 2 > _2D;
   typedef fpa::Image::MinimumSpanningTree< 3 > _3D;
 
-  auto _2d = this->GetInputData( "Input" )->GetITK< _2D >( );
-  auto _3d = this->GetInputData( "Input" )->GetITK< _3D >( );
+  auto _2d = this->GetInputData< _2D >( "Input" );
+  auto _3d = this->GetInputData< _3D >( "Input" );
 
   if     ( _2d != NULL ) this->_GD0( _2d );
   else if( _3d != NULL ) this->_GD0( _3d );
index 8dc341f1b6dbe9ce40fce099ce4dbb81599e3dd6..4e8ca64e73267a09aac2729ecdad61b9a751bba8 100644 (file)
@@ -28,8 +28,7 @@ fpaPlugins::RegionGrowThresholdFunction::
 void fpaPlugins::RegionGrowThresholdFunction::
 _GenerateData( )
 {
-  auto image =
-    this->GetInputData( "ReferenceImage" )->GetITK< itk::DataObject >( );
+  auto image = this->GetInputData< itk::DataObject >( "ReferenceImage" );
   cpPlugins_Image_Demangle_Pixel_AllScalars     ( _GD0, image, 2 );
   else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 );
   else this->_Error( "No valid input image." );
@@ -44,7 +43,7 @@ _GD0( _TImage* image )
     fpa::Image::Functors::RegionGrowThresholdFunction< _TImage >
     _TFunctor;
 
-  auto out = this->GetOutputData( "Output" );
+  auto out = this->GetOutput( "Output" );
   auto f = out->GetITK< _TFunctor >( );
   if( f == NULL )
   {