1 #include "ImageDijkstra.h"
2 #include "MinimumSpanningTree.h"
4 #include <cpPlugins/Image.h>
5 #include <fpa_Instances/Filters.h>
7 // -------------------------------------------------------------------------
8 fpaPlugins::ImageDijkstra::
12 this->_AddInput( "CostFunctor", false );
13 this->_AddOutput< fpaPlugins::MinimumSpanningTree >( "MST" );
14 this->m_Parameters.ConfigureAsBool( "FillNodeQueue" );
15 this->m_Parameters.SetBool( "FillNodeQueue", false );
18 // -------------------------------------------------------------------------
19 fpaPlugins::ImageDijkstra::
24 // -------------------------------------------------------------------------
25 void fpaPlugins::ImageDijkstra::
28 auto image = this->GetInputData< itk::DataObject >( "Input" );
29 cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 );
30 else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 );
31 else this->_Error( "No valid input image." );
34 // -------------------------------------------------------------------------
35 template< class _TImage >
36 void fpaPlugins::ImageDijkstra::
37 _GD0( _TImage* image )
39 typedef float _TPixel;
40 typedef itk::Image< _TPixel, _TImage::ImageDimension > _TOutImage;
41 typedef fpa::Image::Dijkstra< _TImage, _TOutImage > _TFilter;
42 typedef typename _TFilter::TResult _TCost;
43 typedef itk::FunctionBase< _TCost, _TCost > _TCostFunctor;
44 typedef typename _TFilter::TMinimumSpanningTree _TMST;
47 this->GetInputData< itk::LightObject >( "CostFunctor" );
48 _TCostFunctor* functor = NULL;
49 if( base_functor != NULL )
51 functor = dynamic_cast< _TCostFunctor* >( base_functor );
53 this->_Error( "Given cost functor is invalid." );
58 _TFilter* filter = this->_ConfigureFilter< _TFilter >( );
59 filter->SetFillNodeQueue( this->m_Parameters.GetBool( "FillNodeQueue" ) );
60 filter->SetConversionFunction( functor );
63 this->_ExecuteFilter( filter );
65 // Connect remaining output
66 this->GetOutput( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) );
68 std::cout << "Internal: " << filter->GetMTime( ) << std::endl;