1 #include <ImageAlgorithms/Dijkstra.h>
2 #include <cpInstances/DataObjects/Image.h>
4 #include <fpa/Image/Dijkstra.h>
6 // -------------------------------------------------------------------------
7 fpaPluginsImageAlgorithms::Dijkstra::
11 typedef cpPlugins::Pipeline::DataObject _TData;
12 typedef cpInstances::DataObjects::Image _TMST;
14 this->_ConfigureInput< _TData >( "Cost", false, false );
15 this->_ConfigureInput< _TData >( "CostConversion", false, false );
16 this->_ConfigureOutput< _TMST >( "MST" );
18 std::vector< std::string > choices;
19 choices.push_back( "float" );
20 choices.push_back( "double" );
21 this->m_Parameters.ConfigureAsChoices( "ResultType", choices );
22 this->m_Parameters.SetSelectedChoice( "ResultType", "float" );
25 // -------------------------------------------------------------------------
26 fpaPluginsImageAlgorithms::Dijkstra::
31 // -------------------------------------------------------------------------
32 void fpaPluginsImageAlgorithms::Dijkstra::
35 auto o = this->GetInputData( "Input" );
36 cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
37 this->_Error( "Invalid input image." );
40 // -------------------------------------------------------------------------
41 template< class _TImage >
42 void fpaPluginsImageAlgorithms::Dijkstra::
43 _GD0( _TImage* image )
45 typedef itk::Image< float, _TImage::ImageDimension > _TFloat;
46 typedef itk::Image< double, _TImage::ImageDimension > _TDouble;
48 auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
49 if ( rtype == "float" ) this->_GD1< _TImage, _TFloat >( image );
50 else if( rtype == "double" ) this->_GD1< _TImage, _TDouble >( image );
53 // -------------------------------------------------------------------------
54 template< class _TInputImage, class _TOutputImage >
55 void fpaPluginsImageAlgorithms::Dijkstra::
56 _GD1( _TInputImage* image )
58 typedef fpa::Image::Dijkstra< _TInputImage, _TOutputImage > _TFilter;
59 typedef typename _TFilter::TCostConversionFunction _TCostConversion;
60 typedef typename _TFilter::TCostFunction _TCost;
62 auto filter = this->_CreateITK< _TFilter >( );
63 this->_ConfigureFilter( filter, image );
64 auto cost = this->GetInputData< _TCost >( "Cost" );
65 auto conv = this->GetInputData< _TCostConversion >( "CostConversion" );
67 filter->SetCostFunction( cost );
69 filter->SetCostConversionFunction( conv );
71 this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
72 this->GetOutput( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) );