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 std::string fpaPlugins::ImageDijkstra::
28 auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
29 std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
30 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
34 // -------------------------------------------------------------------------
35 template< class _TImage >
36 std::string 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 return( "fpaPlugins::ImageDijkstra: Invalid image type." );
50 this->GetInputData( "CostFunctor" )->GetITK< itk::LightObject >( );
51 _TCostFunctor* functor = NULL;
52 if( base_functor != NULL )
54 functor = dynamic_cast< _TCostFunctor* >( base_functor );
56 return( "fpaPlugins::ImageDijkstra: Given cost functor is invalid." );
61 _TFilter* filter = this->_ConfigureFilter< _TFilter >( );
62 filter->SetFillNodeQueue( this->m_Parameters.GetBool( "FillNodeQueue" ) );
63 filter->SetConversionFunction( functor );
66 this->_ExecuteFilter( filter );
68 // Connect remaining output
69 this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
70 this->GetOutputData( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) );