X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FImage%2FDijkstra.h;h=1df0836a985668ee3f0f526144b63d80f8e2d7f8;hb=cd6b3f8433deaf2ba7c6bb0ece8e5912c760db17;hp=5c2460f97515357f743015919f5e677d17da3505;hpb=56b8bb48cc05a297a3faa264f8f2a88de21ef203;p=FrontAlgorithms.git diff --git a/lib/fpa/Image/Dijkstra.h b/lib/fpa/Image/Dijkstra.h index 5c2460f..1df0836 100644 --- a/lib/fpa/Image/Dijkstra.h +++ b/lib/fpa/Image/Dijkstra.h @@ -1,8 +1,17 @@ -#ifndef __FPA__IMAGE__DIJKSTRA__H__ -#define __FPA__IMAGE__DIJKSTRA__H__ +// ========================================================================= +// @author Leonardo Florez Valencia +// @email florez-l@javeriana.edu.co +// ========================================================================= + +#ifndef __fpa__Image__Dijkstra__h__ +#define __fpa__Image__Dijkstra__h__ #include -#include +#include +#include +#include +#include +#include namespace fpa { @@ -10,64 +19,72 @@ namespace fpa { /** */ - template< class _TInputImage, class _TOutputImage = _TInputImage > + template< class _TInputImage, class _TOutputImage > class Dijkstra - : public fpa::Base::Dijkstra< fpa::Image::Algorithm< _TInputImage, _TOutputImage > > + : 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: - typedef fpa::Base::Dijkstra< fpa::Image::Algorithm< _TInputImage, _TOutputImage > > Superclass; - typedef Dijkstra Self; - typedef itk::SmartPointer< Self > Pointer; + // 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; - // Template arguments - typedef typename Superclass::TVertex TVertex; - typedef typename Superclass::TScalar TScalar; - typedef typename Superclass::TFilter TFilter; - typedef typename Superclass::TVertexCompare TVertexCompare; - typedef typename Superclass::TFrontId TFrontId; - typedef typename Superclass::TCollision TCollision; - typedef typename Superclass::TCollisionsRow TCollisionsRow; - typedef typename Superclass::TCollisions TCollisions; - typedef typename Superclass::TNodeLabel TNodeLabel; - typedef typename Superclass::TNode TNode; - typedef typename Superclass::TNodes TNodes; - typedef typename Superclass::TVertices TVertices; + typedef typename TFilter::TInputImage TInputImage; + typedef typename TFilter::TOutputValue TOutputValue; + typedef typename TFilter::TVertex TVertex; public: itkNewMacro( Self ); - itkTypeMacro( Dijkstra, fpa::Base::Dijkstra ); - - itkBooleanMacro( UseImageSpacing ); - itkGetConstMacro( UseImageSpacing, bool ); - itkSetMacro( UseImageSpacing, bool ); + itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra ); protected: - Dijkstra( ); - virtual ~Dijkstra( ); + Dijkstra( ) : Superclass( ) { } + virtual ~Dijkstra( ) { } + + virtual void _ConfigureOutputs( const TOutputValue& init_value ) override + { + this->Superclass::_ConfigureOutputs( init_value ); + + typename TVertex::OffsetType o; + o.Fill( 0 ); + const TInputImage* input = this->GetInput( ); + TMST* mst = this->GetMinimumSpanningTree( ); + mst->CopyInformation( input ); + mst->SetBufferedRegion( input->GetRequestedRegion( ) ); + mst->Allocate( ); + mst->FillBuffer( o ); + } - // Dijkstra methods to be overloaded - virtual TScalar _Cost( - const TVertex& a, const TVertex& b - ) const fpa_OVERRIDE; + virtual void GenerateData( ) 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( ); + } private: - // Purposely not implemented Dijkstra( const Self& other ); Self& operator=( const Self& other ); - - protected: - bool m_UseImageSpacing; }; } // ecapseman } // ecapseman -#ifndef ITK_MANUAL_INSTANTIATION -# include -#endif - -#endif // __FPA__IMAGE__DIJKSTRA__H__ +#endif // __fpa__Image__Dijkstra__h__ // eof - $RCSfile$