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, 1 );
31 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
32 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
33 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 4 );
37 // -------------------------------------------------------------------------
38 template< class _TImage >
39 std::string cpPluginsImageFilters::ResampleImageFilter::
40 _GD0( _TImage* image )
44 auto choice = this->m_Parameters.GetSelectedChoice( "OutputResolution" );
45 if( choice == "float" )
46 return( this->_GD1< _TImage, float >( image ) );
47 else if( choice == "double" )
48 return( this->_GD1< _TImage, double >( image ) );
49 else return( "ResampleImageFilter: no valid scalar type." );
53 "ResampleImageFilter: No valid input image."
57 // -------------------------------------------------------------------------
58 template< class _TImage, class _TScalar >
59 std::string cpPluginsImageFilters::ResampleImageFilter::
60 _GD1( _TImage* image )
63 itk::ResampleImageFilter< _TImage, _TImage, _TScalar, _TScalar >
68 "ImageFilters::ResampleImageFilter: No valid input image."
72 _TFilter* filter = this->_CreateITK< _TFilter >( );
73 filter->SetInput( image );
76 this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );