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;
// 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 ) );
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;
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 )
+ )
);
}
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 )
+ )
);
}
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
}
// -------------------------------------------------------------------------
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;
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.
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 >::
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$
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;
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.
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 >::
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$
#include <functional>
#include <set>
+#include <vector>
#include <itkConceptChecking.h>
#include <itkProcessObject.h>
{
/**
*/
- 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:
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;
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;
#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 )
}
// -------------------------------------------------------------------------
-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( );
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;
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;
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 )
+ )
);
}
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 )
+ )
);
}
{
}
+// -------------------------------------------------------------------------
+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
*/
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;
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;
{
/**
*/
- 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;
public:
virtual void AddSeed( const TVertex& seed ) override;
+ virtual void AddSeed( const TPoint& seed ) override;
const TLabelImage* GetLabels( ) const;
void SetLabels( const TLabelImage* image );
#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;
}
// -------------------------------------------------------------------------
-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( )
{
}
*/
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;
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 );
virtual ~RandomWalker( );
virtual void _BeforeGenerateData( ) override;
- virtual void _QueueInit( ) override;
+ virtual TNodes _UnifySeeds( ) override;
private:
// Purposely not implemented.
// -------------------------------------------------------------------------
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( );
} // 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__
*/
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;
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;
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 );