]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Flórez-Valencia <leonardo.florez@gmail.com>
Thu, 22 Jun 2017 12:35:50 +0000 (07:35 -0500)
committerLeonardo Flórez-Valencia <leonardo.florez@gmail.com>
Thu, 22 Jun 2017 12:35:50 +0000 (07:35 -0500)
18 files changed:
lib/fpa/Base/Algorithm.h
lib/fpa/Base/Algorithm.hxx
lib/fpa/Base/Dijkstra.h
lib/fpa/Base/Dijkstra.hxx
lib/fpa/Base/DijkstraBase.h
lib/fpa/Base/DijkstraBase.hxx
lib/fpa/Base/RegionGrow.h
lib/fpa/Base/RegionGrow.hxx
lib/fpa/Base/SeedsInterface.h
lib/fpa/Base/SeedsInterface.hxx
lib/fpa/Image/Algorithm.h
lib/fpa/Image/Algorithm.hxx
lib/fpa/Image/Dijkstra.h
lib/fpa/Image/LabelledSeedsInterface.h
lib/fpa/Image/LabelledSeedsInterface.hxx
lib/fpa/Image/RandomWalker.h
lib/fpa/Image/RandomWalker.hxx
lib/fpa/Image/RegionGrow.h

index e5b6f2b0285951b5949a878b1746135e9855dd42..8750c5f7fb2360e2ac3afc44df84ec01d6414bb0 100644 (file)
@@ -35,6 +35,7 @@ namespace fpa
       typedef typename _TSeedsInterface::TInputValue  TInputValue;
       typedef typename _TSeedsInterface::TOutputValue TOutputValue;
       typedef typename _TSeedsInterface::TNode        TNode;
+      typedef typename _TSeedsInterface::TNodes       TNodes;
       typedef typename _TSeedsInterface::TSeeds       TSeeds;
       typedef typename _TSeedsInterface::TVertex      TVertex;
 
index 383db743ad3f9ced6eb3c5c5152771978de9c5b0..44d2520da23e996f40197f7cf8484077100ee820 100644 (file)
@@ -117,12 +117,14 @@ GenerateData( )
   // Init objects
   this->_BeforeGenerateData( );
   this->_ConfigureOutput( this->m_InitValue );
-  this->_InitMarks( this->GetNumberOfSeeds( ) );
+  this->_InitMarks( this->GetSeeds( ).size( ) );
+  TNodes seeds = this->_UnifySeeds( );
+  this->_PrepareSeeds( seeds );
 
   // Init queue
   this->_QueueInit( );
-  typename TSeeds::const_iterator sIt = this->BeginSeeds( );
-  for( ; sIt != this->EndSeeds( ); ++sIt )
+  typename TNodes::const_iterator sIt = seeds.begin( );
+  for( ; sIt != seeds.end( ); ++sIt )
   {
     this->_QueuePush( *sIt );
     this->InvokeEvent( TEvent( sIt->Vertex, sIt->FrontId, true ) );
index 10489dbc3bde669340d4121b413e991106de9c89..c93d575c927c176c41a79bdaf22755e8594ec130 100644 (file)
@@ -27,10 +27,12 @@ namespace fpa
       typedef _TMST TMST;
 
       typedef typename Superclass::TNode        TNode;
+      typedef typename Superclass::TNodes       TNodes;
       typedef typename Superclass::TInputValue  TInputValue;
       typedef typename Superclass::TOutputValue TOutputValue;
       typedef typename Superclass::TFrontId     TFrontId;
       typedef typename Superclass::TVertex      TVertex;
+      typedef typename Superclass::TSeeds       TSeeds;
 
       typedef typename Superclass::TQueue          TQueue;
       typedef typename Superclass::TQueueOrder     TQueueOrder;
index 40058e16e215541709704f455bb03ebbc79b1d6c..be3598173de4c74d81334389ec930ff4b637b120 100644 (file)
@@ -12,8 +12,10 @@ typename fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
 TMST* fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
 GetMinimumSpanningTree( )
 {
-  dynamic_cast< TMST* >(
-    this->itk::ProcessObject::GetOutput( this->m_MSTIdx )
+  return(
+    dynamic_cast< TMST* >(
+      this->itk::ProcessObject::GetOutput( this->m_MSTIdx )
+      )
     );
 }
 
@@ -23,8 +25,10 @@ const typename fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
 TMST* fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
 GetMinimumSpanningTree( ) const
 {
-  dynamic_cast< const TMST* >(
-    this->itk::ProcessObject::GetOutput( this->m_MSTIdx )
+  return(
+    dynamic_cast< const TMST* >(
+      this->itk::ProcessObject::GetOutput( this->m_MSTIdx )
+      )
     );
 }
 
@@ -51,15 +55,20 @@ template< class _TAlgorithm, class _TMST >
 void fpa::Base::Dijkstra< _TAlgorithm, _TMST >::
 _AfterGenerateData( )
 {
-  typedef typename Superclass::TSeedsInterface::TSeeds::iterator _TIt;
-
   this->Superclass::_AfterGenerateData( );
 
   TMST* mst = this->GetMinimumSpanningTree( );
   mst->ClearSeeds( );
   mst->SetCollisions( this->m_Collisions );
-  for( _TIt sIt = this->BeginSeeds( ); sIt != this->EndSeeds( ); ++sIt )
-    mst->AddSeed( sIt->Vertex );
+
+  TSeeds seeds = this->GetSeeds( );
+  typename TSeeds::const_iterator sIt = seeds.begin( );
+  for( ; sIt != seeds.end( ); ++sIt )
+  {
+    if( sIt->IsUnified )
+      mst->AddSeed( sIt->Vertex );
+
+  } // rof
 }
 
 // -------------------------------------------------------------------------
index fd36890738e6c18f88d5b125521b02d4710940da..8878bb75244073c065d1d1c6a34d4d0cf06788e0 100644 (file)
@@ -28,6 +28,7 @@ namespace fpa
       typedef itk::SmartPointer< const Self > ConstPointer;
 
       typedef typename _TAlgorithm::TNode        TNode;
+      typedef typename _TAlgorithm::TNodes       TNodes;
       typedef typename _TAlgorithm::TInputValue  TInputValue;
       typedef typename _TAlgorithm::TOutputValue TOutputValue;
       typedef typename _TAlgorithm::TVertex      TVertex;
@@ -60,11 +61,11 @@ namespace fpa
       virtual ~DijkstraBase( );
 
       virtual TOutputValue _ComputeOutputValue( const TNode& n ) override;
-      virtual void _QueueInit( ) override;
       virtual void _QueueClear( ) override;
       virtual TNode _QueuePop( ) override;
       virtual void _QueuePush( const TNode& node ) override;
       virtual unsigned long _QueueSize( ) const override;
+      virtual void _PrepareSeeds( TNodes& nodes ) override;
 
     private:
       // Purposely not implemented.
index a78554b82107e7d746954a8132dc86c77b64e317..6f4937e82b9f5a5f67bc1ad1395ec5277d67282e 100644 (file)
@@ -50,18 +50,6 @@ _ComputeOutputValue( const TNode& n )
   return( c + this->_GetOutputValue( n.Parent ) );
 }
 
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::DijkstraBase< _TAlgorithm >::
-_QueueInit( )
-{
-  typedef typename Superclass::TSeedsInterface::TSeeds::iterator _TIt;
-
-  this->Superclass::_QueueInit( );
-  for( _TIt sIt = this->BeginSeeds( ); sIt != this->EndSeeds( ); ++sIt )
-    sIt->Value = TOutputValue( 0 );
-}
-
 // -------------------------------------------------------------------------
 template< class _TAlgorithm >
 void fpa::Base::DijkstraBase< _TAlgorithm >::
@@ -109,6 +97,16 @@ _QueueSize( ) const
   return( this->m_Queue.size( ) );
 }
 
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+void fpa::Base::DijkstraBase< _TAlgorithm >::
+_PrepareSeeds( TNodes& nodes )
+{
+  typename TNodes::iterator nIt = nodes.begin( );
+  for( ; nIt != nodes.end( ); ++nIt )
+    nIt->Value = TOutputValue( 0 );
+}
+
 #endif // __fpa__Base__DijkstraBase__hxx__
 
 // eof - $RCSfile$
index 796c90bc333295f621cdf54da37f7ebfa70ba625..34bb0851c589285c6837aaa55f1f7cac3134d3c7 100644 (file)
@@ -28,6 +28,7 @@ namespace fpa
       typedef itk::SmartPointer< const Self > ConstPointer;
 
       typedef typename _TAlgorithm::TNode        TNode;
+      typedef typename _TAlgorithm::TNodes       TNodes;
       typedef typename _TAlgorithm::TInputValue  TInputValue;
       typedef typename _TAlgorithm::TOutputValue TOutputValue;
       typedef typename _TAlgorithm::TFrontId     TFrontId;
@@ -63,11 +64,11 @@ namespace fpa
       virtual ~RegionGrow( );
 
       virtual TOutputValue _ComputeOutputValue( const TNode& n ) override;
-      virtual void _QueueInit( ) override;
       virtual void _QueueClear( ) override;
       virtual TNode _QueuePop( ) override;
       virtual void _QueuePush( const TNode& node ) override;
       virtual unsigned long _QueueSize( ) const override;
+      virtual void _PrepareSeeds( TNodes& nodes ) override;
 
     private:
       // Purposely not implemented.
index 18bb1324518c0d637813e46cbc7b3dd8f7601773..247cf940ef4cbc1adf79d7453d58479f17c2603a 100644 (file)
@@ -103,18 +103,6 @@ _ComputeOutputValue( const TNode& n )
   return( ( inside )? this->m_InsideValue: this->m_InitValue );
 }
 
-// -------------------------------------------------------------------------
-template< class _TAlgorithm >
-void fpa::Base::RegionGrow< _TAlgorithm >::
-_QueueInit( )
-{
-  typedef typename Superclass::TSeedsInterface::TSeeds::iterator _TIt;
-
-  this->Superclass::_QueueInit( );
-  for( _TIt sIt = this->BeginSeeds( ); sIt != this->EndSeeds( ); ++sIt )
-    sIt->Value = this->m_InsideValue;
-}
-
 // -------------------------------------------------------------------------
 template< class _TAlgorithm >
 void fpa::Base::RegionGrow< _TAlgorithm >::
@@ -150,6 +138,16 @@ _QueueSize( ) const
   return( this->m_Queue.size( ) );
 }
 
+// -------------------------------------------------------------------------
+template< class _TAlgorithm >
+void fpa::Base::RegionGrow< _TAlgorithm >::
+_PrepareSeeds( TNodes& nodes )
+{
+  typename TNodes::iterator nIt = nodes.begin( );
+  for( ; nIt != nodes.end( ); ++nIt )
+    nIt->Value = this->m_InsideValue;
+}
+
 #endif // __fpa__Base__RegionGrow__hxx__
 
 // eof - $RCSfile$
index e9c67c3306362f1af8883948445c342129c64654..493b4dbfde30462c9902dde1a12f3a7dbb0e75b5 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <functional>
 #include <set>
+#include <vector>
 
 #include <itkConceptChecking.h>
 #include <itkProcessObject.h>
@@ -18,7 +19,7 @@ namespace fpa
   {
     /**
      */
-    template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare = std::greater< _TVertex > >
+    template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare = std::greater< _TVertex > >
     class SeedsInterface
     {
     public:
@@ -29,12 +30,23 @@ namespace fpa
 
     public:
       typedef _TVertex       TVertex;
+      typedef _TPoint        TPoint;
       typedef _TInputValue   TInputValue;
       typedef _TOutputValue  TOutputValue;
       typedef _TFrontId      TFrontId;
       typedef _TCompare      TCompare;
       typedef SeedsInterface Self;
 
+      struct TSeed
+      {
+        TVertex Vertex;
+        TPoint  Point;
+        bool    IsPoint;
+        bool    IsUnified;
+        TSeed( ) : IsUnified( false ) { }
+      };
+      typedef std::vector< TSeed > TSeeds;
+
       struct TNode
       {
         TVertex  Vertex;
@@ -52,22 +64,22 @@ namespace fpa
             return( cmp( a.Vertex, b.Vertex ) );
           }
       };
-      typedef std::set< TNode, TNodeCompare > TSeeds;
+      typedef std::set< TNode, TNodeCompare > TNodes;
 
     public:
-      unsigned int GetNumberOfSeeds( ) const;
       const TSeeds& GetSeeds( ) const;
-      typename TSeeds::const_iterator BeginSeeds( ) const;
-      typename TSeeds::const_iterator EndSeeds( ) const;
 
       virtual void AddSeed( const TVertex& seed );
-      virtual void RemoveSeed( const TVertex& seed );
+      virtual void AddSeed( const TPoint& seed );
       virtual void ClearSeeds( );
 
     protected:
       SeedsInterface( itk::ProcessObject* filter );
       virtual ~SeedsInterface( );
 
+      virtual TNodes _UnifySeeds( ) = 0;
+      virtual void _PrepareSeeds( TNodes& nodes ) = 0;
+
     protected:
       TSeeds m_Seeds;
       itk::ProcessObject* m_Filter;
index 5c272167310267cf9c12882674d2ae03ec7daaad..5dd666ee53fbf5a719373ea0f27088f22ce569b2 100644 (file)
@@ -7,84 +7,48 @@
 #define __fpa__Base__SeedsInterface__hxx__
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-unsigned int
-fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-GetNumberOfSeeds( ) const
-{
-  return( this->m_Seeds.size( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
+template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
 const typename
-fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
+fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
 TSeeds&
-fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
+fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
 GetSeeds( ) const
 {
   return( this->m_Seeds );
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-typename
-fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-TSeeds::const_iterator
-fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-BeginSeeds( ) const
-{
-  return( this->m_Seeds.begin( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-typename
-fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-TSeeds::const_iterator
-fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-EndSeeds( ) const
-{
-  return( this->m_Seeds.end( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
+template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
 void
-fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
+fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
 AddSeed( const TVertex& seed )
 {
-  TNode node;
-  node.Vertex = seed;
-  node.Parent = seed;
-  node.FrontId = TFrontId( this->m_Seeds.size( ) + 1 );
-  if( this->m_Seeds.insert( node ).second && this->m_Filter != NULL )
+  TSeed s;
+  s.Vertex = seed;
+  s.IsPoint = false;
+  this->m_Seeds.push_back( s );
+  if( this->m_Filter != NULL )
     this->m_Filter->Modified( );
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
+template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
 void
-fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
-RemoveSeed( const TVertex& seed )
+fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
+AddSeed( const TPoint& seed )
 {
-  TNode node;
-  node.Vertex = seed;
-  node.Parent = seed;
-  typename TSeeds::const_iterator i = this->m_Seeds.find( node );
-  if( i != this->m_Seeds.end( ) )
-  {
-    this->m_Seeds.erase( i );
-    if( this->m_Filter != NULL )
-      this->m_Filter->Modified( );
-
-  } // fi
+  TSeed s;
+  s.Point = seed;
+  s.IsPoint = true;
+  this->m_Seeds.push_back( s );
+  if( this->m_Filter != NULL )
+    this->m_Filter->Modified( );
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
+template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
 void
-fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
+fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
 ClearSeeds( )
 {
   if( this->m_Seeds.size( ) > 0 )
@@ -97,16 +61,16 @@ ClearSeeds( )
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
+template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
+fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
 SeedsInterface( itk::ProcessObject* filter )
   : m_Filter( filter )
 {
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
+template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
+fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
 ~SeedsInterface( )
 {
   this->m_Seeds.clear( );
index 5547ff01d9dc233b1aec95eb4ae99663979090dc..12a2f9140994434a9ac85ef1c2b4854f81b5fdc5 100644 (file)
@@ -38,7 +38,10 @@ namespace fpa
       typedef typename Superclass::TFrontId      TFrontId;
       typedef typename Superclass::TNeighborhood TNeighborhood;
       typedef typename Superclass::TNode         TNode;
+      typedef typename Superclass::TNodes        TNodes;
+      typedef typename Superclass::TSeeds        TSeeds;
       typedef typename Superclass::TVertex       TVertex;
+      typedef typename Superclass::TPoint        TPoint;
 
       typedef itk::Image< TFrontId, TInputImage::ImageDimension > TMarks;
 
@@ -56,6 +59,7 @@ namespace fpa
       Algorithm( );
       virtual ~Algorithm( );
 
+      virtual TNodes _UnifySeeds( ) override;
       virtual void _ConfigureOutput( const TOutputValue& v ) override;
       virtual TNeighborhood _GetNeighbors( const TVertex& v ) const override;
       virtual TInputValue _GetInputValue( const TVertex& v ) const override;
index 0ae9b90f993aa5bb0af9b31c11af088795151edc..98592f63d21c375268ff7d1e5fa68ae56f2dd550 100644 (file)
@@ -14,8 +14,10 @@ TMarks*
 fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
 GetMarks( )
 {
-  dynamic_cast< TMarks* >(
-    this->itk::ProcessObject::GetOutput( this->m_MarksIdx )
+  return(
+    dynamic_cast< TMarks* >(
+      this->itk::ProcessObject::GetOutput( this->m_MarksIdx )
+      )
     );
 }
 
@@ -27,8 +29,10 @@ TMarks*
 fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
 GetMarks( ) const
 {
-  dynamic_cast< const TMarks* >(
-    this->itk::ProcessObject::GetOutput( this->m_MarksIdx )
+  return(
+    dynamic_cast< const TMarks* >(
+      this->itk::ProcessObject::GetOutput( this->m_MarksIdx )
+      )
     );
 }
 
@@ -51,6 +55,42 @@ fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInt
 {
 }
 
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
+typename
+fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
+TNodes fpa::Image::Algorithm< _TInputImage, _TOutputImage, _TMarksInterface, _TSeedsInterface >::
+_UnifySeeds( )
+{
+  const TInputImage* input = this->GetInput( );
+  typename TInputImage::RegionType region = input->GetRequestedRegion( );
+  TSeeds seeds = this->GetSeeds( );
+  TNodes nodes;
+
+  typename TSeeds::iterator sIt = seeds.begin( );
+  for( ; sIt != seeds.end( ); ++sIt )
+  {
+    TNode node;
+    if( sIt->IsPoint )
+      input->TransformPhysicalPointToIndex( sIt->Point, sIt->Vertex );
+    else
+      input->TransformIndexToPhysicalPoint( sIt->Vertex, sIt->Point );
+    if( region.IsInside( sIt->Vertex ) )
+    {
+      sIt->IsUnified = true;
+      node.Vertex = sIt->Vertex;
+      node.Parent = node.Vertex;
+      node.FrontId = nodes.size( ) + 1;
+      nodes.insert( node );
+    }
+    else
+      sIt->IsUnified = false;
+      
+  } // rof
+
+  return( nodes );
+}
+
 // -------------------------------------------------------------------------
 template< class _TInputImage, class _TOutputImage, class _TMarksInterface, class _TSeedsInterface >
 void
index d5a1bb9e6f2026b9038dcbda532aaea24dbbe9c7..6882bfea2c245c2fb76031361ed0f62e4d66f81d 100644 (file)
@@ -21,7 +21,7 @@ namespace fpa
      */
     template< class _TInputImage, class _TOutputImage, class _TFrontId = unsigned char >
     class Dijkstra
-      : public fpa::Base::Dijkstra< fpa::Image::Algorithm< _TInputImage, _TOutputImage, fpa::Base::MarksInterfaceWithCollisions< typename _TInputImage::IndexType >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PixelType, typename _TOutputImage::PixelType, _TFrontId, typename _TInputImage::IndexType::LexicographicCompare > >, fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > >
+      : public fpa::Base::Dijkstra< fpa::Image::Algorithm< _TInputImage, _TOutputImage, fpa::Base::MarksInterfaceWithCollisions< typename _TInputImage::IndexType >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, typename _TOutputImage::PixelType, _TFrontId, typename _TInputImage::IndexType::LexicographicCompare > >, fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > >
     {
     public:
       typedef _TInputImage  TInputImage;
@@ -29,12 +29,13 @@ namespace fpa
       typedef _TFrontId     TFrontId;
 
       typedef typename TInputImage::IndexType        TVertex;
+      typedef typename TInputImage::PointType        TPoint;
       typedef typename TVertex::LexicographicCompare TVertexCompare;
       typedef typename TInputImage::PixelType        TInputValue;
       typedef typename TOutputImage::PixelType       TOutputValue;
 
       typedef fpa::Base::MarksInterfaceWithCollisions< TVertex > TMarksInterface;
-      typedef fpa::Base::SeedsInterface< TVertex, TInputValue, TOutputValue, TFrontId, TVertexCompare > TSeedsInterface;
+      typedef fpa::Base::SeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TVertexCompare > TSeedsInterface;
       typedef fpa::Image::Algorithm< TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm;
       typedef fpa::Image::MinimumSpanningTree< TInputImage::ImageDimension > TMST;
 
index 2492b843079ed7c11c8a96db1b21784790e6463b..74ec756a071ee0789510a0ea90c516a028804014 100644 (file)
@@ -16,18 +16,19 @@ namespace fpa
   {
     /**
      */
-    template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare = std::greater< _TVertex > >
+    template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare = std::greater< _TVertex > >
     class LabelledSeedsInterface
-      : public fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >
+      : public fpa::Base::SeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >
     {
     public:
       typedef _TVertex      TVertex;
+      typedef _TPoint       TPoint;
       typedef _TInputValue  TInputValue;
       typedef _TOutputValue TOutputValue;
       typedef _TFrontId     TFrontId;
       typedef _TCompare     TCompare;
       typedef LabelledSeedsInterface Self;
-      typedef fpa::Base::SeedsInterface< TVertex, TInputValue, TOutputValue, TFrontId, TCompare > Superclass;
+      typedef fpa::Base::SeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TCompare > Superclass;
 
       typedef typename Superclass::TNode        TNode;
       typedef typename Superclass::TNodeCompare TNodeCompare;
@@ -37,6 +38,7 @@ namespace fpa
 
     public:
       virtual void AddSeed( const TVertex& seed ) override;
+      virtual void AddSeed( const TPoint& seed ) override;
 
       const TLabelImage* GetLabels( ) const;
       void SetLabels( const TLabelImage* image );
index a9a73c937184dd1413f5990f2b726e2bc28476e8..98cc3347f70534fe1bd723f11c1c2c33b159a9b7 100644 (file)
@@ -10,9 +10,9 @@
 #include <itkExceptionObject.h>
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
+template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
 void
-fpa::Image::LabelledSeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
+fpa::Image::LabelledSeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
 AddSeed( const TVertex& seed )
 {
   std::ostringstream msg;
@@ -26,35 +26,51 @@ AddSeed( const TVertex& seed )
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
+template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
+void
+fpa::Image::LabelledSeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
+AddSeed( const TPoint& seed )
+{
+  std::ostringstream msg;
+  msg << "itk::ERROR: fpa::Image::LabelledSeedsInterface (" << this
+      << "): \"AddSeed( const TPoint& seed )\" is not valid for this class. "
+      << "Use \"SetLabels( TLabelImage* labels )\" instead.";
+  ::itk::ExceptionObject e(
+    __FILE__, __LINE__, msg.str( ).c_str( ), ITK_LOCATION
+    );
+  throw e;
+}
+
+// -------------------------------------------------------------------------
+template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
 const typename 
-fpa::Image::LabelledSeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
+fpa::Image::LabelledSeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
 TLabelImage*
-fpa::Image::LabelledSeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
+fpa::Image::LabelledSeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
 GetLabels( ) const
 {
   return( this->m_LabelImage );
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-void fpa::Image::LabelledSeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
+template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
+void fpa::Image::LabelledSeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
 SetLabels( const TLabelImage* image )
 {
   this->m_LabelImage = image;
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-fpa::Image::LabelledSeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
+template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
+fpa::Image::LabelledSeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
 LabelledSeedsInterface( itk::ProcessObject* filter )
   : Superclass( filter )
 {
 }
 
 // -------------------------------------------------------------------------
-template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
-fpa::Image::LabelledSeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
+template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
+fpa::Image::LabelledSeedsInterface< _TVertex, _TPoint, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
 ~LabelledSeedsInterface( )
 {
 }
index 9e41147febb1cc6b9adcb1ec7dcf8ee1a7adf873..5438f007b992133bc021ebd451fd015568ff0d0c 100644 (file)
@@ -22,20 +22,21 @@ namespace fpa
      */
     template< class _TInputImage, class _TLabelImage, class _TScalar >
     class RandomWalker
-      : public fpa::Base::DijkstraBase< fpa::Image::Algorithm< _TInputImage, itk::Image< _TScalar, _TInputImage::ImageDimension >, fpa::Base::MarksInterface< typename _TInputImage::IndexType >, fpa::Image::LabelledSeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PixelType, _TScalar, typename _TLabelImage::PixelType, typename _TInputImage::IndexType::LexicographicCompare > > >
+      : public fpa::Base::DijkstraBase< fpa::Image::Algorithm< _TInputImage, itk::Image< _TScalar, _TInputImage::ImageDimension >, fpa::Base::MarksInterface< typename _TInputImage::IndexType >, fpa::Image::LabelledSeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, _TScalar, typename _TLabelImage::PixelType, typename _TInputImage::IndexType::LexicographicCompare > > >
     {
     public:
       typedef _TInputImage TInputImage;
       typedef _TLabelImage TLabelImage;
       typedef _TScalar     TScalar;
       typedef typename TInputImage::IndexType        TVertex;
+      typedef typename TInputImage::PointType        TPoint;
       typedef typename TVertex::LexicographicCompare TVertexCompare;
       typedef typename TInputImage::PixelType        TInputValue;
       typedef typename TLabelImage::PixelType        TFrontId;
 
       typedef itk::Image< TScalar, _TInputImage::ImageDimension > TOutputImage;
       typedef fpa::Base::MarksInterface< TVertex > TMarksInterface;
-      typedef fpa::Image::LabelledSeedsInterface< TVertex, TInputValue, _TScalar, TFrontId, TVertexCompare > TSeedsInterface;
+      typedef fpa::Image::LabelledSeedsInterface< TVertex, TPoint, TInputValue, _TScalar, TFrontId, TVertexCompare > TSeedsInterface;
       typedef fpa::Image::Algorithm< _TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm;
 
       typedef RandomWalker                          Self;
@@ -44,6 +45,8 @@ namespace fpa
       typedef itk::SmartPointer< const Self >       ConstPointer;
 
       typedef fpa::Image::Functors::Dijkstra::Function< TInputImage, TScalar > TWeightFunction;
+      typedef typename TSeedsInterface::TNode  TNode;
+      typedef typename TSeedsInterface::TNodes TNodes;
 
     public:
       itkNewMacro( Self );
@@ -57,7 +60,7 @@ namespace fpa
       virtual ~RandomWalker( );
 
       virtual void _BeforeGenerateData( ) override;
-      virtual void _QueueInit( ) override;
+      virtual TNodes _UnifySeeds( ) override;
 
     private:
       // Purposely not implemented.
index 9016e970e987d4a253deb5fd36caf7e1db335914..acaa60ab8118e40510e6e509d9b97b63ec617ac6 100644 (file)
@@ -61,8 +61,9 @@ _BeforeGenerateData( )
 
 // -------------------------------------------------------------------------
 template< class _TInputImage, class _TLabelImage, class _TScalar >
-void fpa::Image::RandomWalker< _TInputImage, _TLabelImage, _TScalar >::
-_QueueInit( )
+typename fpa::Image::RandomWalker< _TInputImage, _TLabelImage, _TScalar >::
+TNodes fpa::Image::RandomWalker< _TInputImage, _TLabelImage, _TScalar >::
+_UnifySeeds( )
 {
   this->m_Seeds.clear( );
   const TLabelImage* lbl = this->GetLabels( );
@@ -98,25 +99,31 @@ _QueueInit( )
 
       } // rof
 
-      typename TSeedsInterface::TNode node;
-      node.Vertex = lIt.GetIndex( );
-      node.Parent = lIt.GetIndex( );
-      node.FrontId = lIt.Get( );
-      node.Value = TScalar( 0 );
       if( !is_seed )
       {
-        this->_Mark( lIt.GetIndex( ), lIt.Get( ) );
+        typename TSeedsInterface::TNode node;
+        node.Vertex = lIt.GetIndex( );
+        node.Parent = lIt.GetIndex( );
+        node.FrontId = lIt.Get( );
+        node.Value = TScalar( 0 );
+        this->_Mark( node.Vertex, node.FrontId );
         this->_UpdateOutputValue( node );
       }
       else
-        this->m_Seeds.insert( node );
+      {
+        typename TSeedsInterface::TSeed seed;
+        seed.Vertex = lIt.GetIndex( );
+        seed.IsPoint = false;
+        this->m_Seeds.push_back( seed );
+
+      } // fi
 
     } // fi
 
   } // rof
 
   // Ok, finish initialization
-  this->Superclass::_QueueInit( );
+  return( this->Superclass::_UnifySeeds( ) );
 }
 
 #endif // __fpa__Image__RandomWalker__hxx__
index 6a094879ef23b1355d15d7f658693e397f34ea3f..2deff2f637de9001588b0ddbd8bdf1e261188ee1 100644 (file)
@@ -19,7 +19,7 @@ namespace fpa
      */
     template< class _TInputImage, class _TOutputImage, class _TFrontId = unsigned char >
     class RegionGrow
-      : public fpa::Base::RegionGrow< fpa::Image::Algorithm< _TInputImage, _TOutputImage, fpa::Base::MarksInterfaceWithCollisions< typename _TInputImage::IndexType >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PixelType, typename _TOutputImage::PixelType, _TFrontId, typename _TInputImage::IndexType::LexicographicCompare > > >
+      : public fpa::Base::RegionGrow< fpa::Image::Algorithm< _TInputImage, _TOutputImage, fpa::Base::MarksInterfaceWithCollisions< typename _TInputImage::IndexType >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, typename _TOutputImage::PixelType, _TFrontId, typename _TInputImage::IndexType::LexicographicCompare > > >
     {
     public:
       typedef _TInputImage  TInputImage;
@@ -27,12 +27,13 @@ namespace fpa
       typedef _TFrontId     TFrontId;
 
       typedef typename TInputImage::IndexType        TVertex;
+      typedef typename TInputImage::PointType        TPoint;
       typedef typename TVertex::LexicographicCompare TVertexCompare;
       typedef typename TInputImage::PixelType        TInputValue;
       typedef typename TOutputImage::PixelType       TOutputValue;
 
       typedef fpa::Base::MarksInterfaceWithCollisions< TVertex > TMarksInterface;
-      typedef fpa::Base::SeedsInterface< TVertex, TInputValue, TOutputValue, TFrontId, TVertexCompare > TSeedsInterface;
+      typedef fpa::Base::SeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TVertexCompare > TSeedsInterface;
       typedef fpa::Image::Algorithm< TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm;
 
       typedef RegionGrow                          Self;
@@ -40,6 +41,9 @@ namespace fpa
       typedef itk::SmartPointer< Self >           Pointer;
       typedef itk::SmartPointer< const Self >     ConstPointer;
 
+      typedef typename TSeedsInterface::TNode  TNode;
+      typedef typename TSeedsInterface::TNodes TNodes;
+
     public:
       itkNewMacro( Self );
       itkTypeMacro( fpa::Image::RegionGrow, fpa::Base::RegionGrow );