1 #include <ITKImageGenericFilters_1/CastImageFilter.h>
2 #include <cpInstances/DataObjects/Image.h>
4 #include <itkCastImageFilter.h>
6 // -------------------------------------------------------------------------
7 cpPluginsITKImageGenericFilters_1::CastImageFilter::
11 this->_ConfigureInput< cpInstances::DataObjects::Image >( "Input", true, false );
12 this->_ConfigureOutput< cpInstances::DataObjects::Image >( "Output" );
13 this->m_Parameters.ConfigureAsScalarTypesChoices( "OutputPixelType" );
16 // -------------------------------------------------------------------------
17 cpPluginsITKImageGenericFilters_1::CastImageFilter::
22 // -------------------------------------------------------------------------
23 void cpPluginsITKImageGenericFilters_1::CastImageFilter::
26 auto o = this->GetInputData( "Input" );
27 cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
28 this->_Error( "Invalid input image." );
31 // -------------------------------------------------------------------------
32 template< class _TInput >
33 void cpPluginsITKImageGenericFilters_1::CastImageFilter::
34 _GD0( _TInput* input )
37 this->m_Parameters.GetSelectedChoice( "OutputPixelType" );
38 if( o_type == "char" ) this->_GD1< _TInput, char >( input );
39 else if( o_type == "short" ) this->_GD1< _TInput, short >( input );
40 else if( o_type == "int" ) this->_GD1< _TInput, int >( input );
41 else if( o_type == "long" ) this->_GD1< _TInput, long >( input );
42 else if( o_type == "uchar" ) this->_GD1< _TInput, unsigned char >( input );
43 else if( o_type == "ushort" ) this->_GD1< _TInput, unsigned short >( input );
44 else if( o_type == "uint" ) this->_GD1< _TInput, unsigned int >( input );
45 else if( o_type == "ulong" ) this->_GD1< _TInput, unsigned long >( input );
46 else if( o_type == "float" ) this->_GD1< _TInput, float >( input );
47 else if( o_type == "double" ) this->_GD1< _TInput, double >( input );
50 // -------------------------------------------------------------------------
51 template< class _TInput, class _TOutputPixel >
52 void cpPluginsITKImageGenericFilters_1::CastImageFilter::
53 _GD1( _TInput* input )
55 typedef itk::Image< _TOutputPixel, _TInput::ImageDimension > _TOutput;
56 typedef itk::CastImageFilter< _TInput, _TOutput > _TFilter;
58 auto filter = this->_CreateITK< _TFilter >( );
59 filter->SetInput( input );
61 this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );