X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FImage%2FDijkstra.h;h=d5a1bb9e6f2026b9038dcbda532aaea24dbbe9c7;hb=e8b46a839b86641f48f593d021234566877ac683;hp=1df0836a985668ee3f0f526144b63d80f8e2d7f8;hpb=f287dfe5d76525d02c37224c0a09ed6277fbbb52;p=FrontAlgorithms.git diff --git a/lib/fpa/Image/Dijkstra.h b/lib/fpa/Image/Dijkstra.h index 1df0836..d5a1bb9 100644 --- a/lib/fpa/Image/Dijkstra.h +++ b/lib/fpa/Image/Dijkstra.h @@ -7,11 +7,11 @@ #define __fpa__Image__Dijkstra__h__ #include +#include #include -#include -#include +#include #include -#include +#include namespace fpa { @@ -19,64 +19,77 @@ namespace fpa { /** */ - template< class _TInputImage, class _TOutputImage > + template< class _TInputImage, class _TOutputImage, class _TFrontId = unsigned char > class Dijkstra - : public fpa::Base::Dijkstra< fpa::Image::Filter< _TInputImage, _TOutputImage >, fpa::Image::MarksInterface< _TInputImage::ImageDimension >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, 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::PixelType, typename _TOutputImage::PixelType, _TFrontId, typename _TInputImage::IndexType::LexicographicCompare > >, fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > > { public: - // Interfaces - typedef fpa::Image::Filter< _TInputImage, _TOutputImage > TFilter; - typedef fpa::Image::MarksInterface< _TInputImage::ImageDimension > TMarksInterface; - typedef fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare > TSeedsInterface; - typedef fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > TMST; - - // Smart pointers - typedef Dijkstra Self; - typedef fpa::Base::Dijkstra< TFilter, TMarksInterface, TSeedsInterface, TMST > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename TFilter::TInputImage TInputImage; - typedef typename TFilter::TOutputValue TOutputValue; - typedef typename TFilter::TVertex TVertex; + typedef _TInputImage TInputImage; + typedef _TOutputImage TOutputImage; + typedef _TFrontId TFrontId; + + typedef typename TInputImage::IndexType TVertex; + 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::Image::Algorithm< TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm; + typedef fpa::Image::MinimumSpanningTree< TInputImage::ImageDimension > TMST; + + typedef Dijkstra Self; + typedef fpa::Base::Dijkstra< TAlgorithm, TMST > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef fpa::Image::Functors::Dijkstra::Function< TInputImage, TOutputValue > TWeightFunction; public: itkNewMacro( Self ); itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra ); protected: - Dijkstra( ) : Superclass( ) { } - virtual ~Dijkstra( ) { } + Dijkstra( ) + : Superclass( ) + { + typedef fpa::Image::Functors::Dijkstra::Identity< TInputImage, TOutputValue > _TDefaultFunction; + this->SetWeightFunction( _TDefaultFunction::New( ) ); + } + virtual ~Dijkstra( ) + { + } - virtual void _ConfigureOutputs( const TOutputValue& init_value ) override + virtual void _ConfigureOutput( const TOutputValue& v ) override { - this->Superclass::_ConfigureOutputs( init_value ); + this->Superclass::_ConfigureOutput( v ); + const TInputImage* in = this->GetInput( ); - typename TVertex::OffsetType o; - o.Fill( 0 ); - const TInputImage* input = this->GetInput( ); TMST* mst = this->GetMinimumSpanningTree( ); - mst->CopyInformation( input ); - mst->SetBufferedRegion( input->GetRequestedRegion( ) ); + mst->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) ); + mst->SetRequestedRegion( in->GetRequestedRegion( ) ); + mst->SetBufferedRegion( in->GetBufferedRegion( ) ); + mst->SetSpacing( in->GetSpacing( ) ); + mst->SetOrigin( in->GetOrigin( ) ); + mst->SetDirection( in->GetDirection( ) ); mst->Allocate( ); - mst->FillBuffer( o ); + + typename TMST::PixelType zero; + zero.Fill( 0 ); + mst->FillBuffer( zero ); } - virtual void GenerateData( ) override + virtual void _BeforeGenerateData( ) override { - // Configure functors with input image - typedef typename TFilter::TOutputValue _TOutputValue; - typedef fpa::Image::Functors::VertexParentBase< _TInputImage, _TOutputValue > _TVFunc; - _TVFunc* vfunc = - dynamic_cast< _TVFunc* >( this->m_VertexFunctor.GetPointer( ) ); - if( vfunc != NULL ) - vfunc->SetImage( this->GetInput( ) ); - - // Ok, continue - this->Superclass::GenerateData( ); + this->Superclass::_BeforeGenerateData( ); + TWeightFunction* wf = + dynamic_cast< TWeightFunction* >( this->GetWeightFunction( ) ); + if( wf != NULL ) + wf->SetImage( this->GetInput( ) ); } private: + // Purposely not implemented. Dijkstra( const Self& other ); Self& operator=( const Self& other ); };