1 #include <cpPluginsImageFilters/ResampleImageFilter.h>
2 #include <cpPlugins/Image.h>
3 #include <cpPlugins_Instances/ResamplingFilters.h>
5 // -------------------------------------------------------------------------
6 cpPluginsImageFilters::ResampleImageFilter::
10 this->_AddInput( "Input" );
11 this->_AddOutput< cpPlugins::Image >( "Output" );
12 std::vector< std::string > choices;
13 choices.push_back( "float" );
14 choices.push_back( "double" );
15 this->m_Parameters.ConfigureAsChoices( "ScalarType", choices );
16 this->m_Parameters.SetSelectedChoice( "ScalarType", "float" );
19 // -------------------------------------------------------------------------
20 cpPluginsImageFilters::ResampleImageFilter::
21 ~ResampleImageFilter( )
25 // -------------------------------------------------------------------------
26 std::string cpPluginsImageFilters::ResampleImageFilter::
29 auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
30 std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
31 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
33 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 1 );
34 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 4 );
39 // -------------------------------------------------------------------------
40 template< class _TImage >
41 std::string cpPluginsImageFilters::ResampleImageFilter::
42 _GD0( _TImage* image )
46 auto choice = this->m_Parameters.GetSelectedChoice( "OutputResolution" );
47 if( choice == "float" )
48 return( this->_GD1< _TImage, float >( image ) );
49 else if( choice == "double" )
50 return( this->_GD1< _TImage, double >( image ) );
51 else return( "ResampleImageFilter: no valid scalar type." );
55 "ResampleImageFilter: No valid input image."
59 // -------------------------------------------------------------------------
60 template< class _TImage, class _TScalar >
61 std::string cpPluginsImageFilters::ResampleImageFilter::
62 _GD1( _TImage* image )
65 itk::ResampleImageFilter< _TImage, _TImage, _TScalar, _TScalar >
70 "ImageFilters::ResampleImageFilter: No valid input image."
74 _TFilter* filter = this->_CreateITK< _TFilter >( );
75 filter->SetInput( image );
78 this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );