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::PointType, 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 TInputImage::PointType TPoint;
33 typedef typename TVertex::LexicographicCompare TVertexCompare;
34 typedef typename TInputImage::PixelType TInputValue;
35 typedef typename TOutputImage::PixelType TOutputValue;
37 typedef fpa::Base::MarksInterfaceWithCollisions< TVertex > TMarksInterface;
38 typedef fpa::Base::SeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TFrontId, TVertexCompare > TSeedsInterface;
39 typedef fpa::Image::Algorithm< TInputImage, TOutputImage, TMarksInterface, TSeedsInterface > TAlgorithm;
40 typedef fpa::Image::MinimumSpanningTree< TInputImage::ImageDimension > TMST;
42 typedef Dijkstra Self;
43 typedef fpa::Base::Dijkstra< TAlgorithm, TMST > Superclass;
44 typedef itk::SmartPointer< Self > Pointer;
45 typedef itk::SmartPointer< const Self > ConstPointer;
47 typedef fpa::Image::Functors::Dijkstra::Function< TInputImage, TOutputValue > TWeightFunction;
51 itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra );
57 typedef fpa::Image::Functors::Dijkstra::Identity< TInputImage, TOutputValue > _TDefaultFunction;
58 this->SetWeightFunction( _TDefaultFunction::New( ) );
64 virtual void _ConfigureOutput( const TOutputValue& v ) override
66 this->Superclass::_ConfigureOutput( v );
67 const TInputImage* in = this->GetInput( );
69 TMST* mst = this->GetMinimumSpanningTree( );
70 mst->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) );
71 mst->SetRequestedRegion( in->GetRequestedRegion( ) );
72 mst->SetBufferedRegion( in->GetBufferedRegion( ) );
73 mst->SetSpacing( in->GetSpacing( ) );
74 mst->SetOrigin( in->GetOrigin( ) );
75 mst->SetDirection( in->GetDirection( ) );
78 typename TMST::PixelType zero;
80 mst->FillBuffer( zero );
83 virtual void _BeforeGenerateData( ) override
85 this->Superclass::_BeforeGenerateData( );
87 dynamic_cast< TWeightFunction* >( this->GetWeightFunction( ) );
89 wf->SetImage( this->GetInput( ) );
93 // Purposely not implemented.
94 Dijkstra( const Self& other );
95 Self& operator=( const Self& other );
102 #endif // __fpa__Image__Dijkstra__h__