#include #include #include #include // ------------------------------------------------------------------------- cpPluginsImageGenericFilters::CastImageFilter:: CastImageFilter( ) : Superclass( ) { typedef cpPlugins::DataObjects::Image _TImage; this->_ConfigureInput< _TImage >( "Input", true, false ); this->_ConfigureOutput< _TImage >( "Output" ); this->m_Parameters.ConfigureAsScalarTypesChoices( "CastType" ); } // ------------------------------------------------------------------------- cpPluginsImageGenericFilters::CastImageFilter:: ~CastImageFilter( ) { } // ------------------------------------------------------------------------- void cpPluginsImageGenericFilters::CastImageFilter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TInput > void cpPluginsImageGenericFilters::CastImageFilter:: _GD0( _TInput* input ) { std::string out_res = this->m_Parameters.GetSelectedChoice( "CastType" ); #ifdef cpPlugins_CONFIG_INTEGER_TYPES_char if( out_res == "char" ) this->_GD1< _TInput, char >( input ); if( out_res == "uchar" ) this->_GD1< _TInput, unsigned char >( input ); #endif // cpPlugins_CONFIG_INTEGER_TYPES_char #ifdef cpPlugins_CONFIG_INTEGER_TYPES_short if( out_res == "short" ) this->_GD1< _TInput, short >( input ); if( out_res == "ushort" ) this->_GD1< _TInput, unsigned short >( input ); #endif // cpPlugins_CONFIG_INTEGER_TYPES_short #ifdef cpPlugins_CONFIG_INTEGER_TYPES_int if( out_res == "int" ) this->_GD1< _TInput, int >( input ); if( out_res == "uint" ) this->_GD1< _TInput, unsigned int >( input ); #endif // cpPlugins_CONFIG_INTEGER_TYPES_int #ifdef cpPlugins_CONFIG_INTEGER_TYPES_long if( out_res == "long" ) this->_GD1< _TInput, long >( input ); if( out_res == "ulong" ) this->_GD1< _TInput, unsigned long >( input ); #endif // cpPlugins_CONFIG_INTEGER_TYPES_long #ifdef cpPlugins_CONFIG_REAL_TYPES_float if( out_res == "float" ) this->_GD1< _TInput, float >( input ); #endif // cpPlugins_CONFIG_REAL_TYPES_float #ifdef cpPlugins_CONFIG_REAL_TYPES_double if( out_res == "double" ) this->_GD1< _TInput, double >( input ); #endif // cpPlugins_CONFIG_REAL_TYPES_double } // ------------------------------------------------------------------------- template< class _TInput, class _TOutputPixel > void cpPluginsImageGenericFilters::CastImageFilter:: _GD1( _TInput* input ) { typedef itk::Image< _TOutputPixel, _TInput::ImageDimension > _TOutput; typedef itk::CastImageFilter< _TInput, _TOutput > _TFilter; auto filter = this->_CreateITK< _TFilter >( ); filter->SetInput( input ); filter->Update( ); this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); } // eof - $RCSfile$