2 #include <cpPlugins/Interface/Image.h>
3 #include <cpPlugins/Interface/PolyLineParametricPath.h>
4 #include <cpExtensions/Algorithms/CPRFilter.h>
5 #include <itkInterpolateImageFunction.h>
7 // -------------------------------------------------------------------------
8 cpPlugins::BasicFilters::CPRFilter::
12 this->_AddInput( "InputImage", true );
13 this->_AddInput( "InputAxis", true );
14 this->_AddInput( "Interpolator", false );
15 this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
17 this->m_Parameters->ConfigureAsUint( "NumberOfSlices" );
18 this->m_Parameters->ConfigureAsReal( "SliceRadius" );
19 std::vector< std::string > choices;
20 choices.push_back( "float" );
21 choices.push_back( "double" );
22 this->m_Parameters->ConfigureAsChoices( "ScalarType", choices );
24 this->m_Parameters->SetUint( "NumberOfSlices", 0 );
25 this->m_Parameters->SetReal( "SliceRadius", 10 );
26 this->m_Parameters->SetSelectedChoice( "ScalarType", "float" );
29 // -------------------------------------------------------------------------
30 cpPlugins::BasicFilters::CPRFilter::
35 // -------------------------------------------------------------------------
36 std::string cpPlugins::BasicFilters::CPRFilter::
40 this->GetInputData< cpPlugins::Interface::Image >( "InputImage" );
42 return( "CPRFilter: No input image." );
44 itk::DataObject* itk_image = NULL;
46 cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 );
47 else r = "CPRFilter: Input image type not supported.";
51 // -------------------------------------------------------------------------
53 std::string cpPlugins::BasicFilters::CPRFilter::
54 _GD0( itk::DataObject* dobj )
56 I* image = dynamic_cast< I* >( dobj );
58 auto choice = this->m_Parameters->GetSelectedChoice( "ScalarType" );
59 if( choice == "float" )
60 return( this->_GD1< I, float >( image ) );
61 else if( choice == "double" )
62 return( this->_GD1< I, double >( image ) );
64 return( "CPRFilter: Scalar type not supported." );
67 // -------------------------------------------------------------------------
68 template< class I, class S >
69 std::string cpPlugins::BasicFilters::CPRFilter::
72 typedef cpExtensions::Algorithms::CPRFilter< I, S > _Filter;
73 typedef itk::PolyLineParametricPath< I::ImageDimension > _Path;
74 typedef itk::InterpolateImageFunction< I, S > _Interpolator;
77 this->GetInputData< cpPlugins::Interface::PolyLineParametricPath >(
79 )->GetITK< _Path >( );
81 this->GetInputData< cpPlugins::Interface::DataObject >( "Interpolator" );
82 _Interpolator* interpolator = NULL;
84 interpolator = w_int->GetITK< _Interpolator >( );
87 _Filter* filter = this->_CreateITK< _Filter >( );
88 filter->SetInput( image );
89 filter->SetAxis( axis );
90 if( interpolator != NULL )
91 filter->SetInterpolator( interpolator );
92 filter->SetNumberOfSlices( this->m_Parameters->GetUint( "NumberOfSlices" ) );
93 filter->SetSliceRadius( this->m_Parameters->GetReal( "SliceRadius" ) );
98 this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
99 out->SetITK< I >( filter->GetOutput( ) );