RGBImageToOtherChannelsFilter( )
: Superclass( )
{
- typedef cpPlugins::Interface::Parameters TParameters;
+ this->_AddInput( "Input" );
+ this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
- this->m_ClassName = "cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter";
- this->m_ClassCategory = "ImageToImageFilter";
- this->SetNumberOfInputs( 1 );
- this->SetNumberOfOutputs( 1 );
- this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
-
- this->m_DefaultParameters.Configure( TParameters::String, "OutChannel" );
- this->m_Parameters = this->m_DefaultParameters;
+ std::vector< std::string > choices;
+ choices.push_back( "HSV" );
+ choices.push_back( "YPbPr" );
+ this->m_Parameters->ConfigureAsChoices( "OutChannel", choices );
}
// -------------------------------------------------------------------------
{
}
-// -------------------------------------------------------------------------
-#define cpPlugins_Plugins_RGBImageToOtherChannelsFilter( P, D, I, O, r, f ) \
- cpPlugins_Image_Input_Demangle( P< char >, D, I, O, r, f ); \
- else cpPlugins_Image_Input_Demangle( P< short >, D, I, O, r, f ); \
- else cpPlugins_Image_Input_Demangle( P< int >, D, I, O, r, f ); \
- else cpPlugins_Image_Input_Demangle( P< long >, D, I, O, r, f ); \
- else cpPlugins_Image_Input_Demangle( \
- P< unsigned char >, D, I, O, r, f \
- ); \
- else cpPlugins_Image_Input_Demangle( \
- P< unsigned short >, D, I, O, r, f \
- ); \
- else cpPlugins_Image_Input_Demangle( \
- P< unsigned int >, D, I, O, r, f \
- ); \
- else cpPlugins_Image_Input_Demangle( \
- P< unsigned long >, D, I, O, r, f \
- )
-
// -------------------------------------------------------------------------
std::string cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter::
_GenerateData( )
{
- cpPlugins::Interface::Image* image =
- this->GetInput< cpPlugins::Interface::Image >( 0 );
- if( image == NULL )
- return( "RGBImageToOtherChannelsFilter: No input image." );
-
+ auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" );
itk::DataObject* itk_image = NULL;
std::string r = "";
- cpPlugins_Plugins_RGBImageToOtherChannelsFilter(
- itk::RGBPixel, 2, image, itk_image, r, _DemangleOutput
- );
- else cpPlugins_Plugins_RGBImageToOtherChannelsFilter(
- itk::RGBPixel, 3, image, itk_image, r, _DemangleOutput
- );
- else cpPlugins_Plugins_RGBImageToOtherChannelsFilter(
- itk::RGBPixel, 4, image, itk_image, r, _DemangleOutput
- );
+ cpPlugins_Image_Demangle_AllRGBTypes( 2, image, itk_image, r, _GD0 );
+ else cpPlugins_Image_Demangle_AllRGBTypes( 3, image, itk_image, r, _GD0 );
+ else cpPlugins_Image_Demangle_AllRGBTypes( 4, image, itk_image, r, _GD0 );
else r = "RGBImageToOtherChannelsFilter: Input image type not supported.";
return( r );
}
// -------------------------------------------------------------------------
template< class I >
std::string cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter::
-_DemangleOutput( itk::DataObject* image )
+_GD0( itk::DataObject* image )
{
typedef typename I::PixelType _P;
- std::string outc = this->m_Parameters.GetValueAsString( "OutChannel" );
+ std::string outc = this->m_Parameters->GetSelectedChoice( "OutChannel" );
std::string r = "";
using namespace cpExtensions::Algorithms;
_F;
// Configure filter
- _F* filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) );
- if( filter == NULL )
- {
- this->m_RealProcessObject = _F::New( );
- filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) );
-
- } // fi
+ _F* filter = this->_CreateITK< _F >( );
filter->SetInput( dynamic_cast< I* >( image ) );
filter->Update( );
// Connect output
- cpPlugins::Interface::Image* out =
- this->GetOutput< cpPlugins::Interface::Image >( 0 );
- if( out != NULL )
- {
- out->SetITKImage< _O >( filter->GetOutput( ) );
- return( "" );
- }
- else
- return( "RGBImageToOtherChannelsFilter: output not correctly created." );
-
+ auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
+ out->SetITK( filter->GetOutput( ) );
return( "" );
}