1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
6 #ifndef __fpa__Image__Dijkstra__h__
7 #define __fpa__Image__Dijkstra__h__
9 #include <fpa/Base/Dijkstra.h>
10 #include <fpa/Base/MarksInterfaceWithCollisions.h>
11 #include <fpa/Base/SeedsInterface.h>
12 #include <fpa/Image/Algorithm.h>
13 #include <fpa/Image/MinimumSpanningTree.h>
14 #include <fpa/Image/Functors/Dijkstra/Identity.h>
22 template< class _TInputImage, class _TOutputImage, class _TFrontId = unsigned char >
24 : 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 > >
27 typedef _TInputImage TInputImage;
28 typedef _TOutputImage TOutputImage;
29 typedef _TFrontId TFrontId;
31 typedef typename TInputImage::IndexType TVertex;
32 typedef typename TVertex::LexicographicCompare TVertexCompare;
33 typedef typename TInputImage::PixelType TInputValue;
34 typedef typename TOutputImage::PixelType TOutputValue;
36 typedef fpa::Base::MarksInterfaceWithCollisions< TVertex > TMarksInterface;
37 typedef fpa::Base::SeedsInterface< TVertex, TInputValue, TOutputValue, TFrontId, TVertexCompare > TSeedsInterface;
38 typedef fpa::Image::Algorithm< TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm;
39 typedef fpa::Image::MinimumSpanningTree< TInputImage::ImageDimension > TMST;
41 typedef Dijkstra Self;
42 typedef fpa::Base::Dijkstra< TAlgorithm, TMST > Superclass;
43 typedef itk::SmartPointer< Self > Pointer;
44 typedef itk::SmartPointer< const Self > ConstPointer;
46 typedef fpa::Image::Functors::Dijkstra::Function< TInputImage, TOutputValue > TWeightFunction;
50 itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra );
56 typedef fpa::Image::Functors::Dijkstra::Identity< TInputImage, TOutputValue > _TDefaultFunction;
57 this->SetWeightFunction( _TDefaultFunction::New( ) );
63 virtual void _ConfigureOutput( const TOutputValue& v ) override
65 this->Superclass::_ConfigureOutput( v );
66 const TInputImage* in = this->GetInput( );
68 TMST* mst = this->GetMinimumSpanningTree( );
69 mst->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) );
70 mst->SetRequestedRegion( in->GetRequestedRegion( ) );
71 mst->SetBufferedRegion( in->GetBufferedRegion( ) );
72 mst->SetSpacing( in->GetSpacing( ) );
73 mst->SetOrigin( in->GetOrigin( ) );
74 mst->SetDirection( in->GetDirection( ) );
77 typename TMST::PixelType zero;
79 mst->FillBuffer( zero );
82 virtual void _BeforeGenerateData( ) override
84 this->Superclass::_BeforeGenerateData( );
86 dynamic_cast< TWeightFunction* >( this->GetWeightFunction( ) );
88 wf->SetImage( this->GetInput( ) );
92 // Purposely not implemented.
93 Dijkstra( const Self& other );
94 Self& operator=( const Self& other );
101 #endif // __fpa__Image__Dijkstra__h__