X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FImage%2FDijkstra.h;h=1df0836a985668ee3f0f526144b63d80f8e2d7f8;hb=617f49bff4a6db5ed51b4f767c3634d1915fdced;hp=48d7a79b8bf026385a88a35c176033c48439e284;hpb=6fcc9fc78c44fa789bf092e2897cb6b391259b42;p=FrontAlgorithms.git diff --git a/lib/fpa/Image/Dijkstra.h b/lib/fpa/Image/Dijkstra.h index 48d7a79..1df0836 100644 --- a/lib/fpa/Image/Dijkstra.h +++ b/lib/fpa/Image/Dijkstra.h @@ -1,99 +1,90 @@ -#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 +#include +#include +#include namespace fpa { namespace Image { /** - * @param I Input image type - * @param O Output image type */ - template< class I, class O > + template< class _TInputImage, class _TOutputImage > class Dijkstra - : public Algorithm< I, O, fpa::Base::Dijkstra< typename I::IndexType, typename I::PixelType, typename O::PixelType, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, itk::ImageToImageFilter< I, O > > > + : 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< typename I::IndexType, typename I::PixelType, typename O::PixelType, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, itk::ImageToImageFilter< I, O > > TBaseAlgorithm; - - typedef Dijkstra Self; - typedef Algorithm< I, O, TBaseAlgorithm > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef typename Superclass::TInputImage TInputImage; - typedef typename Superclass::TOutputImage TOutputImage; - typedef typename Superclass::TVertex TVertex; - typedef typename Superclass::TValue TValue; - typedef typename Superclass::TResult TResult; - - typedef typename Superclass::TStartEvent TStartEvent; - typedef typename Superclass::TStartLoopEvent TStartLoopEvent; - typedef typename Superclass::TEndEvent TEndEvent; - typedef typename Superclass::TEndLoopEvent TEndLoopEvent; - typedef typename Superclass::TAliveEvent TAliveEvent; - typedef typename Superclass::TFrontEvent TFrontEvent; - typedef typename Superclass::TFreezeEvent TFreezeEvent; - - typedef typename Superclass::TStartBacktrackingEvent TStartBacktrackingEvent; - typedef typename Superclass::TEndBacktrackingEvent TEndBacktrackingEvent; - typedef typename Superclass::TBacktrackingEvent TBacktrackingEvent; - - typedef fpa::Image::Functors::ImageCostFunction< TInputImage, TResult > TCostFunction; - typedef itk::FunctionBase< TResult, TResult > TConversionFunction; - - protected: - typedef typename Superclass::_TVertices _TVertices; - typedef typename Superclass::_TCollision _TCollision; - typedef typename Superclass::_TCollisionsRow _TCollisionsRow; - typedef typename Superclass::_TCollisions _TCollisions; - typedef typename Superclass::_TNode _TNode; - typedef typename Superclass::_TNodes _TNodes; + // 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; public: itkNewMacro( Self ); - itkTypeMacro( Dijkstra, Algorithm ); - - itkGetObjectMacro( CostFunction, TCostFunction ); - itkGetObjectMacro( ConversionFunction, TConversionFunction ); - - itkGetConstObjectMacro( CostFunction, TCostFunction ); - itkGetConstObjectMacro( ConversionFunction, TConversionFunction ); - - itkSetObjectMacro( CostFunction, TCostFunction ); - itkSetObjectMacro( ConversionFunction, TConversionFunction ); + itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra ); protected: - Dijkstra( ); - virtual ~Dijkstra( ); - - virtual TResult _Cost( const TVertex& v, const TVertex& p ) const; - - virtual void _BeforeGenerateData( ); - virtual void _InitResults( ); + 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 ); + } + + 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: - typename TCostFunction::Pointer m_CostFunction; - typename TConversionFunction::Pointer m_ConversionFunction; }; } // ecapseman } // ecapseman -#include - -#endif // __FPA__IMAGE__DIJKSTRA__H__ +#endif // __fpa__Image__Dijkstra__h__ // eof - $RCSfile$