X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FImage%2FDijkstra.h;h=6882bfea2c245c2fb76031361ed0f62e4d66f81d;hb=fe01e92d9bce3519fa2a0936b6180ca7b057a87a;hp=1464d3cfd2953d01bfa2c0714437bba3ce42ad12;hpb=9622bd5b833a8845881003228207e0caca59b081;p=FrontAlgorithms.git diff --git a/lib/fpa/Image/Dijkstra.h b/lib/fpa/Image/Dijkstra.h index 1464d3c..6882bfe 100644 --- a/lib/fpa/Image/Dijkstra.h +++ b/lib/fpa/Image/Dijkstra.h @@ -1,58 +1,104 @@ -#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 */ - template< class I, class C > + template< class _TInputImage, class _TOutputImage, class _TFrontId = unsigned char > class Dijkstra - : public Algorithm< I, fpa::Base::Dijkstra< typename I::IndexType, C, typename I::PixelType, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, itk::ImageToImageFilter< I, itk::Image< C, I::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: - // Standard class typdedefs - typedef typename I::IndexType TVertex; - typedef typename I::PixelType TVertexValue; - typedef itk::Image< C, I::ImageDimension > TCostImage; - typedef itk::ImageToImageFilter< I, TCostImage > TBaseFilter; - typedef fpa::Base::Dijkstra< TVertex, C, TVertexValue, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, TBaseFilter > TBaseAlgorithm; - - typedef Dijkstra Self; - typedef Algorithm< I, TBaseAlgorithm > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; + typedef _TInputImage TInputImage; + typedef _TOutputImage TOutputImage; + 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, TPoint, 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( Dijkstra, fpaBaseDijkstra ); + itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra ); protected: Dijkstra( ) : Superclass( ) - { } + { + typedef fpa::Image::Functors::Dijkstra::Identity< TInputImage, TOutputValue > _TDefaultFunction; + this->SetWeightFunction( _TDefaultFunction::New( ) ); + } virtual ~Dijkstra( ) - { } + { + } + + virtual void _ConfigureOutput( const TOutputValue& v ) override + { + this->Superclass::_ConfigureOutput( v ); + const TInputImage* in = this->GetInput( ); + + TMST* mst = this->GetMinimumSpanningTree( ); + 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( ); + + typename TMST::PixelType zero; + zero.Fill( 0 ); + mst->FillBuffer( zero ); + } + + virtual void _BeforeGenerateData( ) override + { + this->Superclass::_BeforeGenerateData( ); + TWeightFunction* wf = + dynamic_cast< TWeightFunction* >( this->GetWeightFunction( ) ); + if( wf != NULL ) + wf->SetImage( this->GetInput( ) ); + } private: - // Purposely not implemented - Dijkstra( const Self& ); - void operator=( const Self& ); + // Purposely not implemented. + Dijkstra( const Self& other ); + Self& operator=( const Self& other ); }; } // ecapseman } // ecapseman -#endif // __FPA__IMAGE__DIJKSTRA__H__ +#endif // __fpa__Image__Dijkstra__h__ // eof - $RCSfile$