From: Leonardo Florez-Valencia Date: Mon, 21 Sep 2015 15:23:27 +0000 (+0200) Subject: ... X-Git-Tag: v0.1~372 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=54e12e973942f6ddfe6c606acf2fd93480ca6165;p=cpPlugins.git ... --- diff --git a/appli/examples/CMakeLists.txt b/appli/examples/CMakeLists.txt index 1e5b943..7d12653 100644 --- a/appli/examples/CMakeLists.txt +++ b/appli/examples/CMakeLists.txt @@ -5,16 +5,16 @@ SET( EXAMPLES_PROGRAMS - ## example_TestParameters + example_TestParameters example_LoadPlugins example_ReadWriteImage example_MarchingCubes example_OtsuFilter + example_RGBImageToHSVChannels + example_RGBImageToYPbPrChannels ## example_ReadImageSeriesWriteImage ## example_ReadQuadEdgeMesh ## example_RenderQuadEdgeMesh - ## example_RGBImageToHSVChannels - ## example_RGBImageToYPbPrChannels ## example_MPR ) diff --git a/appli/examples/example_RGBImageToHSVChannels.cxx b/appli/examples/example_RGBImageToHSVChannels.cxx index 4e8e6bf..03d0eea 100644 --- a/appli/examples/example_RGBImageToHSVChannels.cxx +++ b/appli/examples/example_RGBImageToHSVChannels.cxx @@ -3,103 +3,73 @@ #include #include -#include #include -// ------------------------------------------------------------------------- -typedef cpPlugins::Interface::Interface TInterface; -typedef cpPlugins::Interface::DataObject TDataObject; -typedef TInterface::TClasses TClasses; -typedef cpPlugins::Interface::ProcessObject TProcessObject; -typedef cpPlugins::Interface::Parameters TParameters; - -// ------------------------------------------------------------------------- -void SaveImage( - TInterface& plugins, const std::string& fname, TDataObject* image - ) -{ - TProcessObject::Pointer writer; - writer = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageWriter" ); - if( writer.IsNull( ) ) - { - std::cerr << "No suitable writer found in plugins." << std::endl; - return; - - } // fi - - // Configure reader - TParameters writer_params = writer->GetDefaultParameters( ); - writer_params.SetValueAsString( "FileName", fname ); - writer->SetParameters( writer_params ); - - writer->SetInput( 0, image ); - std::string msg = writer->Update( ); - if( msg != "" ) - std::cerr << "ERROR: " << msg << std::endl; -} - -// ------------------------------------------------------------------------- int main( int argc, char* argv[] ) { - if( argc < 8 ) + if( argc < 4 ) { std::cerr << "Usage: " << argv[ 0 ] << " plugins_file" - << " input_image" - << " output_hue_image output_saturation_image output_value_image" - << " dimensions pixel_type" << std::endl; + << " input_image output_image" << std::endl; return( 1 ); } // fi - std::string plugins_file = argv[ 1 ]; - std::string input_image_file = argv[ 2 ]; - std::string output_hue_image_file = argv[ 3 ]; - std::string output_saturation_image_file = argv[ 4 ]; - std::string output_value_image_file = argv[ 5 ]; - unsigned int dimensions = std::atoi( argv[ 6 ] ); - std::string pixel_type = argv[ 7 ]; // Create interface - + typedef cpPlugins::Interface::Interface TInterface; + typedef TInterface::TClasses TClasses; TInterface plugins; - plugins.Load( plugins_file ); - - // Create objects - TProcessObject::Pointer reader; - TProcessObject::Pointer filter; - - reader = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageReader" ); - if( reader.IsNull( ) ) + if( !plugins.Load( argv[ 1 ] ) ) { - std::cerr << "No suitable reader found in plugins." << std::endl; + std::cerr << "Failed to load plugins." << std::endl; return( 1 ); } // fi - filter = plugins.CreateProcessObject( "cpPlugins::Plugins::RGBImageToHSVChannelsFilter" ); - if( filter.IsNull( ) ) + + // Create objects + typedef cpPlugins::Interface::ProcessObject TProcessObject; + typedef cpPlugins::Interface::Parameters TParameters; + cpPlugins::Interface::ProcessObject::Pointer reader, writer, filter; + reader = plugins.CreateProcessObject( "cpPlugins::ImageReader" ); + writer = plugins.CreateProcessObject( "cpPlugins::ImageWriter" ); + filter = plugins.CreateProcessObject( "cpPlugins::RGBImageToOtherChannelsFilter"); + if( reader.IsNull( ) || writer.IsNull( ) || filter.IsNull( ) ) { - std::cerr << "No suitable filter found in plugins." << std::endl; + std::cerr << "No suitable objects found in plugins." << std::endl; return( 1 ); } // fi // Configure reader TParameters reader_params = reader->GetDefaultParameters( ); - reader_params.AddValueToStringList( "FileNames", input_image_file ); - reader_params.SetValueAsString( "PixelType", pixel_type ); - reader_params.SetValueAsUint( "ImageDimension", dimensions ); - reader_params.SetValueAsUint( "IsColorImage", 1 ); + for( int i = 2; i < argc - 1; ++i ) + reader_params.AddValueToStringList( "FileNames", argv[ i ] ); reader->SetParameters( reader_params ); + // Configure filter + TParameters filter_params = filter->GetDefaultParameters( ); + filter_params.SetValueAsString( "OutChannel", "HSV" ); + filter->SetParameters( filter_params ); + + // Configure writer + TParameters writer_params = writer->GetDefaultParameters( ); + writer_params.SetValueAsString( "FileName", argv[ argc - 1 ] ); + writer->SetParameters( writer_params ); + // Connect pipeline filter->SetInput( 0, reader->GetOutput( 0 ) ); + writer->SetInput( 0, filter->GetOutput( 0 ) ); - // Save outputs - SaveImage( plugins, output_hue_image_file, filter->GetOutput( 0 ) ); - SaveImage( plugins, output_saturation_image_file, filter->GetOutput( 1 ) ); - SaveImage( plugins, output_value_image_file, filter->GetOutput( 2 ) ); + // Execute pipeline + std::string err = writer->Update( ); + if( err != "" ) + { + std::cerr << "ERROR: " << err << std::endl; + return( 1 ); + } // fi return( 0 ); } diff --git a/appli/examples/example_RGBImageToYPbPrChannels.cxx b/appli/examples/example_RGBImageToYPbPrChannels.cxx index f94f203..7806289 100644 --- a/appli/examples/example_RGBImageToYPbPrChannels.cxx +++ b/appli/examples/example_RGBImageToYPbPrChannels.cxx @@ -3,106 +3,73 @@ #include #include -#include #include -// ------------------------------------------------------------------------- -typedef cpPlugins::Interface::Interface TInterface; -typedef cpPlugins::Interface::DataObject TDataObject; -typedef TInterface::TClasses TClasses; -typedef cpPlugins::Interface::ProcessObject TProcessObject; -typedef cpPlugins::Interface::Parameters TParameters; - -// ------------------------------------------------------------------------- -void SaveImage( - TInterface& plugins, const std::string& fname, TDataObject* image - ) -{ - TProcessObject::Pointer writer; - writer = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageWriter" ); - if( writer.IsNull( ) ) - { - std::cerr << "No suitable writer found in plugins." << std::endl; - return; - - } // fi - - // Configure reader - TParameters writer_params = writer->GetDefaultParameters( ); - writer_params.SetValueAsString( "FileName", fname ); - writer->SetParameters( writer_params ); - - writer->SetInput( 0, image ); - std::string msg = writer->Update( ); - if( msg != "" ) - std::cerr << "ERROR: " << msg << std::endl; -} - -// ------------------------------------------------------------------------- int main( int argc, char* argv[] ) { - if( argc < 8 ) + if( argc < 4 ) { std::cerr << "Usage: " << argv[ 0 ] << " plugins_file" - << " input_image" - << " output_hue_image output_saturation_image output_value_image" - << " dimensions pixel_type" << std::endl; + << " input_image output_image" << std::endl; return( 1 ); } // fi - std::string plugins_file = argv[ 1 ]; - std::string input_image_file = argv[ 2 ]; - std::string output_hue_image_file = argv[ 3 ]; - std::string output_saturation_image_file = argv[ 4 ]; - std::string output_value_image_file = argv[ 5 ]; - unsigned int dimensions = std::atoi( argv[ 6 ] ); - std::string pixel_type = argv[ 7 ]; // Create interface - + typedef cpPlugins::Interface::Interface TInterface; + typedef TInterface::TClasses TClasses; TInterface plugins; - plugins.Load( plugins_file ); - - // Create objects - TProcessObject::Pointer reader; - TProcessObject::Pointer filter; - - reader = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageReader" ); - if( reader.IsNull( ) ) + if( !plugins.Load( argv[ 1 ] ) ) { - std::cerr << "No suitable reader found in plugins." << std::endl; + std::cerr << "Failed to load plugins." << std::endl; return( 1 ); } // fi - filter = plugins.CreateProcessObject( "cpPlugins::Plugins::RGBImageToYPbPrChannelsFilter" ); - if( filter.IsNull( ) ) + + // Create objects + typedef cpPlugins::Interface::ProcessObject TProcessObject; + typedef cpPlugins::Interface::Parameters TParameters; + cpPlugins::Interface::ProcessObject::Pointer reader, writer, filter; + reader = plugins.CreateProcessObject( "cpPlugins::ImageReader" ); + writer = plugins.CreateProcessObject( "cpPlugins::ImageWriter" ); + filter = plugins.CreateProcessObject( "cpPlugins::RGBImageToOtherChannelsFilter"); + if( reader.IsNull( ) || writer.IsNull( ) || filter.IsNull( ) ) { - std::cerr << "No suitable filter found in plugins." << std::endl; + std::cerr << "No suitable objects found in plugins." << std::endl; return( 1 ); } // fi // Configure reader TParameters reader_params = reader->GetDefaultParameters( ); - reader_params.AddValueToStringList( "FileNames", input_image_file ); - reader_params.SetValueAsString( "PixelType", pixel_type ); - reader_params.SetValueAsUint( "ImageDimension", dimensions ); - reader_params.SetValueAsUint( "IsColorImage", 1 ); + for( int i = 2; i < argc - 1; ++i ) + reader_params.AddValueToStringList( "FileNames", argv[ i ] ); reader->SetParameters( reader_params ); - // Connect pipeline + // Configure filter TParameters filter_params = filter->GetDefaultParameters( ); - filter_params.SetValueAsString( "OutputPixelType", "float" ); + filter_params.SetValueAsString( "OutChannel", "YPbPr" ); filter->SetParameters( filter_params ); + + // Configure writer + TParameters writer_params = writer->GetDefaultParameters( ); + writer_params.SetValueAsString( "FileName", argv[ argc - 1 ] ); + writer->SetParameters( writer_params ); + + // Connect pipeline filter->SetInput( 0, reader->GetOutput( 0 ) ); + writer->SetInput( 0, filter->GetOutput( 0 ) ); - // Save outputs - SaveImage( plugins, output_hue_image_file, filter->GetOutput( 0 ) ); - SaveImage( plugins, output_saturation_image_file, filter->GetOutput( 1 ) ); - SaveImage( plugins, output_value_image_file, filter->GetOutput( 2 ) ); + // Execute pipeline + std::string err = writer->Update( ); + if( err != "" ) + { + std::cerr << "ERROR: " << err << std::endl; + return( 1 ); + } // fi return( 0 ); } diff --git a/lib/cpExtensions/Algorithms/RGBExtractFunction.h b/lib/cpExtensions/Algorithms/RGBExtractFunction.h index 9dd11b5..ec7126b 100644 --- a/lib/cpExtensions/Algorithms/RGBExtractFunction.h +++ b/lib/cpExtensions/Algorithms/RGBExtractFunction.h @@ -10,7 +10,6 @@ #include #include -#include namespace cpExtensions { @@ -18,20 +17,21 @@ namespace cpExtensions { /** */ - template< class O > + template< class P > struct RGBExtractFunction { - typedef RGBExtractFunction Self; - typedef itk::Vector< O, 3 > TOutPixel; + typedef RGBExtractFunction Self; + typedef P TOutPixel; + typedef typename P::ValueType TValue; template< class Tr, class Tg, class Tb > - TOutPixel operator()( const Tr& r, const Tg& g, const Tb& b ) const + P operator()( const Tr& r, const Tg& g, const Tb& b ) const { - TOutPixel rgb; - rgb[ 0 ] = O( r ); - rgb[ 1 ] = O( g ); - rgb[ 2 ] = O( b ); - return( rgb ); + P out; + out[ 0 ] = TValue( r ); + out[ 1 ] = TValue( g ); + out[ 2 ] = TValue( b ); + return( out ); } template< class C > diff --git a/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.h b/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.h index eec919d..4ce6754 100644 --- a/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.h +++ b/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.h @@ -33,19 +33,6 @@ namespace cpExtensions itkNewMacro( Self ); itkTypeMacro( RGBImageToOtherChannelsFilter, itkImageToImageFilter ); - public: - O* GetChannel1( ); - O* GetChannel2( ); - O* GetChannel3( ); - - const O* GetChannel1( ) const; - const O* GetChannel2( ) const; - const O* GetChannel3( ) const; - - void GraftChannel1( O* c1 ); - void GraftChannel2( O* c2 ); - void GraftChannel3( O* c3 ); - protected: RGBImageToOtherChannelsFilter( ); virtual ~RGBImageToOtherChannelsFilter( ); diff --git a/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.hxx b/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.hxx index 3c8f49d..74578d4 100644 --- a/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.hxx +++ b/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.hxx @@ -12,99 +12,6 @@ #include #include -// ------------------------------------------------------------------------- -template< class I, class O, class C > -O* cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GetChannel1( ) -{ - return( this->GetOutput( 0 ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -O* cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GetChannel2( ) -{ - return( this->GetOutput( 1 ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -O* cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GetChannel3( ) -{ - return( this->GetOutput( 2 ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -const O* cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GetChannel1( ) const -{ - if( this->GetNumberOfOutputs( ) > 0 ) - return( - dynamic_cast< const O* >( - this->itk::ProcessObject::GetOutput( 0 ) - ) - ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -const O* cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GetChannel2( ) const -{ - if( this->GetNumberOfOutputs( ) > 1 ) - return( - dynamic_cast< const O* >( - this->itk::ProcessObject::GetOutput( 1 ) - ) - ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -const O* cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GetChannel3( ) const -{ - if( this->GetNumberOfOutputs( ) > 2 ) - return( - dynamic_cast< const O* >( - this->itk::ProcessObject::GetOutput( 2 ) - ) - ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -void cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GraftChannel1( O* hue ) -{ - this->GraftNthOutput( 0, hue ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -void cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GraftChannel2( O* saturation ) -{ - this->GraftNthOutput( 1, saturation ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -void cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GraftChannel3( O* value ) -{ - this->GraftNthOutput( 2, value ); -} - // ------------------------------------------------------------------------- template< class I, class O, class C > cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: @@ -112,13 +19,10 @@ RGBImageToOtherChannelsFilter( ) : Superclass( ) { this->SetNumberOfRequiredInputs( 1 ); - this->SetNumberOfRequiredOutputs( 3 ); - for( unsigned int i = 0; i < 3; i++ ) - { - typename O::Pointer o = O::New( ); - this->SetNthOutput( i, o ); + this->SetNumberOfRequiredOutputs( 1 ); - } // rof + typename O::Pointer o = O::New( ); + this->SetNthOutput( 0, o ); } // ------------------------------------------------------------------------- @@ -153,24 +57,13 @@ ThreadedGenerateData( // typedef typename TInputPixel::ComponentType _TComponent; typedef itk::ImageRegionConstIterator< I > _TInIt; typedef itk::ImageRegionIterator< O > _TOutIt; - typedef typename C::TOutPixel _TOutPixel; _TInIt inIt( this->GetInput( ), region ); - _TOutIt hIt( this->GetChannel1( ), region ); - _TOutIt sIt( this->GetChannel2( ), region ); - _TOutIt vIt( this->GetChannel3( ), region ); + _TOutIt outIt( this->GetOutput( ), region ); inIt.GoToBegin( ); - hIt.GoToBegin( ); - sIt.GoToBegin( ); - vIt.GoToBegin( ); - for( ; !inIt.IsAtEnd( ); ++inIt, ++hIt, ++sIt, ++vIt ) - { - _TOutPixel other = this->Converter( inIt.Get( ) ); - hIt.Set( other[ 0 ] ); - sIt.Set( other[ 1 ] ); - vIt.Set( other[ 2 ] ); - - } // rof + outIt.GoToBegin( ); + for( ; !inIt.IsAtEnd( ); ++inIt, ++outIt ) + outIt.Set( this->Converter( inIt.Get( ) ) ); } #endif // __CPEXTENSIONS__ALGORITHMS__RGBIMAGETOOTHERCHANNELSFILTER__HXX__ diff --git a/lib/cpExtensions/Algorithms/RGBToHSVFunction.h b/lib/cpExtensions/Algorithms/RGBToHSVFunction.h index 326ec5d..b10f295 100644 --- a/lib/cpExtensions/Algorithms/RGBToHSVFunction.h +++ b/lib/cpExtensions/Algorithms/RGBToHSVFunction.h @@ -10,7 +10,6 @@ #include #include -#include namespace cpExtensions { @@ -18,24 +17,25 @@ namespace cpExtensions { /** */ - template< class O > + template< class P > struct RGBToHSVFunction { - typedef RGBToHSVFunction Self; - typedef itk::Vector< O, 3 > TOutPixel; + typedef RGBToHSVFunction Self; + typedef P TOutPixel; + typedef typename P::ValueType TValue; template< class Tr, class Tg, class Tb > - TOutPixel operator()( const Tr& r, const Tg& g, const Tb& b ) const + P operator()( const Tr& r, const Tg& g, const Tb& b ) const { static const double mVal = - double( std::numeric_limits< O >::max( ) ); + double( std::numeric_limits< TValue >::max( ) ); static const double _0 = double( 0 ); static const double _1 = double( 1 ); static const double _2 = double( 2 ); static const double _3 = double( 3 ); static const double _2pi = _2 * double( vnl_math::pi ); - TOutPixel hsv; + P hsv; double R = double( r ); double G = double( g ); @@ -50,20 +50,20 @@ namespace cpExtensions if( A != _0 ) A = std::acos( ( RG + RB ) / ( _2 * A ) ); A /= _2pi; - hsv[ 0 ] = O( mVal * ( ( G >= B )? A: _1 - A ) ); + hsv[ 0 ] = TValue( mVal * ( ( G >= B )? A: _1 - A ) ); // Saturation if( sRGB != _0 ) { double C = ( G < R )? G: R; C = ( B < C )? B: C; - hsv[ 1 ] = O( mVal * ( _1 - ( ( _3 * C ) / sRGB ) ) ); + hsv[ 1 ] = TValue( mVal * ( _1 - ( ( _3 * C ) / sRGB ) ) ); } else - hsv[ 1 ] = O( 0 ); + hsv[ 1 ] = TValue( 0 ); // Value - hsv[ 2 ] = O( sRGB / _3 ); + hsv[ 2 ] = TValue( sRGB / _3 ); return( hsv ); } diff --git a/lib/cpExtensions/Algorithms/RGBToRGBFunction.h b/lib/cpExtensions/Algorithms/RGBToRGBFunction.h deleted file mode 100644 index b7d5908..0000000 --- a/lib/cpExtensions/Algorithms/RGBToRGBFunction.h +++ /dev/null @@ -1,51 +0,0 @@ -// ------------------------------------------------------------------------- -// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) -// ------------------------------------------------------------------------- - -#ifndef __CPEXTENSIONS__ALGORITHMS__RGBTORGBFUNCTION__H__ -#define __CPEXTENSIONS__ALGORITHMS__RGBTORGBFUNCTION__H__ - -#include -#include -#include - -namespace cpExtensions -{ - namespace Algorithms - { - /** - */ - template< class O > - struct RGBToRGBFunction - { - typedef RGBToRGBFunction Self; - typedef itk::Vector< O, 3 > TOutPixel; - - template< class Tr, class Tg, class Tb > - TOutPixel operator()( const Tr& r, const Tg& g, const Tb& b ) const - { - TOutPixel rgb; - rgb[ 0 ] = O( r ); - rgb[ 1 ] = O( g ); - rgb[ 2 ] = O( b ); - return( rgb ); - } - - template< class C > - TOutPixel operator()( const itk::RGBPixel< C >& rgb ) const - { - return( - this->operator()( - rgb.GetRed( ), rgb.GetGreen( ), rgb.GetBlue( ) - ) - ); - } - }; - - } // ecapseman - -} // ecapseman - -#endif // __CPEXTENSIONS__ALGORITHMS__RGBTORGBFUNCTION__H__ - -// eof - $RCSfile$ diff --git a/lib/cpExtensions/Algorithms/RGBToYPbPrFunction.h b/lib/cpExtensions/Algorithms/RGBToYPbPrFunction.h index fb9da02..83085fe 100644 --- a/lib/cpExtensions/Algorithms/RGBToYPbPrFunction.h +++ b/lib/cpExtensions/Algorithms/RGBToYPbPrFunction.h @@ -20,29 +20,36 @@ namespace cpExtensions { /** */ - template< class O > + template< class P > struct RGBToYPbPrFunction { - typedef RGBToYPbPrFunction Self; - typedef itk::Vector< O, 3 > TOutPixel; + typedef RGBToYPbPrFunction Self; + typedef P TOutPixel; + typedef typename P::ValueType TValue; template< class Tr, class Tg, class Tb > - TOutPixel operator()( const Tr& r, const Tg& g, const Tb& b ) const + P operator()( const Tr& r, const Tg& g, const Tb& b ) const { - static const O M[] = + static const double M[] = { - O( 0.2990 ), O( 0.5870 ), O( 0.1140 ), - O( -0.1687 ), O( -0.3313 ), O( 0.5000 ), - O( 0.5000 ), O( -0.4187 ), O( -0.0813 ) + double( 0.2990 ), double( 0.5870 ), double( 0.1140 ), + double( -0.1687 ), double( -0.3313 ), double( 0.5000 ), + double( 0.5000 ), double( -0.4187 ), double( -0.0813 ) }; - static const vnl_matrix< O > vM( M, 3, 3 ); - static const itk::Matrix< O, 3, 3 > iM( vM ); + static const vnl_matrix< double > vM( M, 3, 3 ); + static const itk::Matrix< double, 3, 3 > iM( vM ); - TOutPixel rgb; - rgb[ 0 ] = O( r ); - rgb[ 1 ] = O( g ); - rgb[ 2 ] = O( b ); - return( iM * rgb ); + itk::Vector< double, 3 > rgb; + rgb[ 0 ] = double( r ); + rgb[ 1 ] = double( b ); + rgb[ 2 ] = double( g ); + rgb = iM * rgb; + + P out; + out[ 0 ] = TValue( rgb[ 0 ] ); + out[ 1 ] = TValue( rgb[ 1 ] ); + out[ 2 ] = TValue( rgb[ 2 ] ); + return( out ); } template< class C > diff --git a/lib/cpPlugins/Interface/BaseProcessObjects.h b/lib/cpPlugins/Interface/BaseProcessObjects.h index 229a0c3..04c2982 100644 --- a/lib/cpPlugins/Interface/BaseProcessObjects.h +++ b/lib/cpPlugins/Interface/BaseProcessObjects.h @@ -82,24 +82,60 @@ else cpPlugins_Image_Input_Demangle( \ itk::RGBPixel< short >, D, I, O, r, f \ ); \ + else cpPlugins_Image_Input_Demangle( \ + itk::RGBPixel< int >, D, I, O, r, f \ + ); \ + else cpPlugins_Image_Input_Demangle( \ + itk::RGBPixel< long >, D, I, O, r, f \ + ); \ else cpPlugins_Image_Input_Demangle( \ itk::RGBPixel< unsigned char >, D, I, O, r, f \ ); \ else cpPlugins_Image_Input_Demangle( \ itk::RGBPixel< unsigned short >, D, I, O, r, f \ ); \ + else cpPlugins_Image_Input_Demangle( \ + itk::RGBPixel< unsigned int >, D, I, O, r, f \ + ); \ + else cpPlugins_Image_Input_Demangle( \ + itk::RGBPixel< unsigned long >, D, I, O, r, f \ + ); \ + else cpPlugins_Image_Input_Demangle( \ + itk::RGBPixel< float >, D, I, O, r, f \ + ); \ + else cpPlugins_Image_Input_Demangle( \ + itk::RGBPixel< double >, D, I, O, r, f \ + ); \ else cpPlugins_Image_Input_Demangle( \ itk::RGBAPixel< char >, D, I, O, r, f \ ); \ else cpPlugins_Image_Input_Demangle( \ itk::RGBAPixel< short >, D, I, O, r, f \ ); \ + else cpPlugins_Image_Input_Demangle( \ + itk::RGBAPixel< int >, D, I, O, r, f \ + ); \ + else cpPlugins_Image_Input_Demangle( \ + itk::RGBAPixel< long >, D, I, O, r, f \ + ); \ else cpPlugins_Image_Input_Demangle( \ itk::RGBAPixel< unsigned char >, D, I, O, r, f \ ); \ else cpPlugins_Image_Input_Demangle( \ itk::RGBAPixel< unsigned short >, D, I, O, r, f \ ); \ + else cpPlugins_Image_Input_Demangle( \ + itk::RGBAPixel< unsigned int >, D, I, O, r, f \ + ); \ + else cpPlugins_Image_Input_Demangle( \ + itk::RGBAPixel< unsigned long >, D, I, O, r, f \ + ); \ + else cpPlugins_Image_Input_Demangle( \ + itk::RGBAPixel< float >, D, I, O, r, f \ + ); \ + else cpPlugins_Image_Input_Demangle( \ + itk::RGBAPixel< double >, D, I, O, r, f \ + ); \ else cpPlugins_Image_Input_Demangle( \ itk::Offset< D >, D, I, O, r, f \ ); \ diff --git a/lib/cpPlugins/Interface/Image.hxx b/lib/cpPlugins/Interface/Image.hxx index 640e01c..b6794a3 100644 --- a/lib/cpPlugins/Interface/Image.hxx +++ b/lib/cpPlugins/Interface/Image.hxx @@ -132,6 +132,9 @@ // ------------------------------------------------------------------------- // ITK base clases + +#ifndef cpPlugins_Interface_EXPORTS + cpPlugins_Image_Import_AllDimensions( char ); cpPlugins_Image_Import_AllDimensions( short ); cpPlugins_Image_Import_AllDimensions( int ); @@ -207,6 +210,8 @@ cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< unsigned char > ); cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< unsigned short > ); cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< unsigned int > ); cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< unsigned long > ); +cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< float > ); +cpPlugins_VTKImage_Import_AllDimensions( itk::RGBPixel< double > ); cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< char > ); cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< short > ); @@ -216,6 +221,8 @@ cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< unsigned char > ); cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< unsigned short > ); cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< unsigned int > ); cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< unsigned long > ); +cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< float > ); +cpPlugins_VTKImage_Import_AllDimensions( itk::RGBAPixel< double > ); cpPlugins_VTKImageArray_Import_AllDimensions( Vector, float ); cpPlugins_VTKImageArray_Import_AllDimensions( Vector, double ); @@ -236,6 +243,8 @@ cpPlugins_VTKImageArray_Import_AllDimensions( cpPlugins_VTKImage_Import( itk::DiffusionTensor3D< float >, 3 ); cpPlugins_VTKImage_Import( itk::DiffusionTensor3D< double >, 3 ); +#endif // cpPlugins_Interface_EXPORTS + // ------------------------------------------------------------------------- template< class I > void cpPlugins::Interface::Image:: diff --git a/lib/cpPlugins/Interface/Instances_itkImage.cxx b/lib/cpPlugins/Interface/Instances_itkImage.cxx index a040f44..ab8d38a 100644 --- a/lib/cpPlugins/Interface/Instances_itkImage.cxx +++ b/lib/cpPlugins/Interface/Instances_itkImage.cxx @@ -92,6 +92,8 @@ cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< unsigned char > ); cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< unsigned short > ); cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< unsigned int > ); cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< unsigned long > ); +cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< float > ); +cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< double > ); cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< char > ); cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< short > ); @@ -101,6 +103,8 @@ cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< unsigned char > ); cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< unsigned short > ); cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< unsigned int > ); cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< unsigned long > ); +cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< float > ); +cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< double > ); cpPlugins_ImageArray_Export_AllDimensions( Vector, float ); cpPlugins_ImageArray_Export_AllDimensions( Vector, double ); diff --git a/lib/cpPlugins/Interface/Mesh.hxx b/lib/cpPlugins/Interface/Mesh.hxx index 9163971..e897f61 100644 --- a/lib/cpPlugins/Interface/Mesh.hxx +++ b/lib/cpPlugins/Interface/Mesh.hxx @@ -13,6 +13,9 @@ ) // ------------------------------------------------------------------------- + +#ifndef cpPlugins_Interface_EXPORTS + cpPlugins_Mesh_Import( Mesh, float, 2 ); cpPlugins_Mesh_Import( Mesh, double, 2 ); cpPlugins_Mesh_Import( Mesh, float, 3 ); @@ -22,6 +25,8 @@ cpPlugins_Mesh_Import( QuadEdgeMesh, double, 2 ); cpPlugins_Mesh_Import( QuadEdgeMesh, float, 3 ); cpPlugins_Mesh_Import( QuadEdgeMesh, double, 3 ); +#endif // cpPlugins_Interface_EXPORTS + // ------------------------------------------------------------------------- template< class M > void cpPlugins::Interface::Mesh:: diff --git a/lib/cpPlugins/Interface/ProcessObject.h b/lib/cpPlugins/Interface/ProcessObject.h index d25516d..3381fa8 100644 --- a/lib/cpPlugins/Interface/ProcessObject.h +++ b/lib/cpPlugins/Interface/ProcessObject.h @@ -83,566 +83,6 @@ namespace cpPlugins #include - -// ------------------------------------------------------------------------- -/* TODO - #define cpPlugins_Image_Demangle_Methods( c ) \ - std::string _DemangleImageDimension( itk::DataObject* o ); \ - std::string _DemangleImagePixel( unsigned int d, itk::DataObject* o ); - - // ------------------------------------------------------------------------- - #define cpPlugins_Image_Demangle_Methods_Code( c, f ) \ - std::string c::_DemangleImageDimension( itk::DataObject* o ) \ - { \ - std::string r = ""; \ - if( dynamic_cast< itk::ImageBase< 1 >* >( o ) != NULL ) \ - { \ - cpPlugins_Image_Array_Demangle( \ - itk::Vector, float, 1, 1, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::Vector, double, 1, 1, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::Point, float, 1, 1, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::Point, double, 1, 1, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::CovariantVector, float, 1, 1, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::CovariantVector, double, 1, 1, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::SymmetricSecondRankTensor, float, 1, 1, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::SymmetricSecondRankTensor, double, 1, 1, o, f, r \ - ); \ - else r = this->_DemangleImagePixel( 1, o ); \ - } \ - else if( dynamic_cast< itk::ImageBase< 2 >* >( o ) != NULL ) \ - { \ - cpPlugins_Image_Demangle( \ - itk::RGBPixel< char >, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBPixel< short >, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBPixel< unsigned char >, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBPixel< unsigned short >, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBAPixel< char >, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBAPixel< short >, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBAPixel< unsigned char >, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBAPixel< unsigned short >, 2, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::Vector, float, 2, 2, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::Vector, double, 2, 2, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::Point, float, 2, 2, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::Point, double, 2, 2, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::CovariantVector, float, 2, 2, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::CovariantVector, double, 2, 2, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::SymmetricSecondRankTensor, float, 2, 2, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::SymmetricSecondRankTensor, double, 2, 2, o, f, r \ - ); \ - else r = this->_DemangleImagePixel( 2, o ); \ - } \ - else if( dynamic_cast< itk::ImageBase< 3 >* >( o ) != NULL ) \ - { \ - cpPlugins_Image_Demangle( \ - itk::RGBPixel< char >, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBPixel< short >, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBPixel< unsigned char >, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBPixel< unsigned short >, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBAPixel< char >, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBAPixel< short >, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBAPixel< unsigned char >, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBAPixel< unsigned short >, 3, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::Vector, float, 3, 3, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::Vector, double, 3, 3, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::Point, float, 3, 3, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::Point, double, 3, 3, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::CovariantVector, float, 3, 3, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::CovariantVector, double, 3, 3, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::SymmetricSecondRankTensor, float, 3, 3, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::SymmetricSecondRankTensor, double, 3, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::DiffusionTensor3D< float >, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::DiffusionTensor3D< double >, 3, o, f, r \ - ); \ - else r = this->_DemangleImagePixel( 3, o ); \ - } \ - else if( dynamic_cast< itk::ImageBase< 4 >* >( o ) != NULL ) \ - { \ - cpPlugins_Image_Demangle( \ - itk::RGBPixel< char >, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBPixel< short >, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBPixel< unsigned char >, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBPixel< unsigned short >, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBAPixel< char >, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBAPixel< short >, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBAPixel< unsigned char >, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::RGBAPixel< unsigned short >, 4, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::Vector, float, 4, 4, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::Vector, double, 4, 4, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::Point, float, 4, 4, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::Point, double, 4, 4, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::CovariantVector, float, 4, 4, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::CovariantVector, double, 4, 4, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::SymmetricSecondRankTensor, float, 4, 4, o, f, r \ - ); \ - else cpPlugins_Image_Array_Demangle( \ - itk::SymmetricSecondRankTensor, double, 4, 4, o, f, r \ - ); \ - else r = this->_DemangleImagePixel( 4, o ); \ - } \ - else \ - r = \ - std::string( #c ) + \ - std::string( ": Image dimension not supported." ); \ - return( r ); \ - } \ - std::string c::_DemangleImagePixel( \ - unsigned int d, itk::DataObject* o \ - ) \ - { \ - std::string r = ""; \ - if( d == 1 ) \ - { \ - cpPlugins_Image_Demangle( \ - char, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - short, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - int, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - long, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned char, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned short, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned int, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned long, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - float, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - double, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - std::complex< float >, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - std::complex< double >, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::Offset< 1 >, 1, o, f, r \ - ); \ - else r = std::string( #c ) + std::string( ": Image type." ); \ - } \ - else if( d == 2 ) \ - { \ - cpPlugins_Image_Demangle( \ - char, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - short, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - int, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - long, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned char, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned short, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned int, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned long, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - float, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - double, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - std::complex< float >, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - std::complex< double >, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::Offset< 2 >, 2, o, f, r \ - ); \ - else r = std::string( #c ) + std::string( ": Image type." ); \ - } \ - else if( d == 3 ) \ - { \ - cpPlugins_Image_Demangle( \ - char, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - short, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - int, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - long, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned char, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned short, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned int, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned long, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - float, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - double, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - std::complex< float >, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - std::complex< double >, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::Offset< 3 >, 3, o, f, r \ - ); \ - else r = std::string( #c ) + std::string( ": Image type." ); \ - } \ - else if( d == 4 ) \ - { \ - cpPlugins_Image_Demangle( \ - char, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - short, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - int, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - long, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned char, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned short, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned int, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned long, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - float, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - double, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - std::complex< float >, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - std::complex< double >, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - itk::Offset< 4 >, 4, o, f, r \ - ); \ - else r = std::string( #c ) + std::string( ": Image type." ); \ - } \ - else \ - r = \ - std::string( #c ) + \ - std::string( ": Image dimension not supported." ); \ - return( r ); \ - } - - // ------------------------------------------------------------------------- - #define cpPlugins_Image_Demangle_Methods_Code_Only_Scalars( c, f ) \ - std::string c::_DemangleImageDimension( itk::DataObject* o ) \ - { \ - std::string r = ""; \ - if( dynamic_cast< itk::ImageBase< 1 >* >( o ) != NULL ) \ - r = this->_DemangleImagePixel( 1, o ); \ - else if( dynamic_cast< itk::ImageBase< 2 >* >( o ) != NULL ) \ - r = this->_DemangleImagePixel( 2, o ); \ - else if( dynamic_cast< itk::ImageBase< 3 >* >( o ) != NULL ) \ - r = this->_DemangleImagePixel( 3, o ); \ - else if( dynamic_cast< itk::ImageBase< 4 >* >( o ) != NULL ) \ - r = this->_DemangleImagePixel( 4, o ); \ - else \ - r = \ - std::string( #c ) + \ - std::string( ": Image dimension not supported." ); \ - return( r ); \ - } \ - std::string c::_DemangleImagePixel( \ - unsigned int d, itk::DataObject* o \ - ) \ - { \ - std::string r = ""; \ - if( d == 1 ) \ - { \ - cpPlugins_Image_Demangle( \ - char, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - short, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - int, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - long, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned char, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned short, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned int, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned long, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - float, 1, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - double, 1, o, f, r \ - ); \ - else r = std::string( #c ) + std::string( ": Image type." ); \ - } \ - else if( d == 2 ) \ - { \ - cpPlugins_Image_Demangle( \ - char, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - short, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - int, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - long, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned char, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned short, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned int, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned long, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - float, 2, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - double, 2, o, f, r \ - ); \ - else r = std::string( #c ) + std::string( ": Image type." ); \ - } \ - else if( d == 3 ) \ - { \ - cpPlugins_Image_Demangle( \ - char, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - short, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - int, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - long, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned char, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned short, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned int, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned long, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - float, 3, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - double, 3, o, f, r \ - ); \ - else r = std::string( #c ) + std::string( ": Image type." ); \ - } \ - else if( d == 4 ) \ - { \ - cpPlugins_Image_Demangle( \ - char, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - short, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - int, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - long, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned char, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned short, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned int, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - unsigned long, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - float, 4, o, f, r \ - ); \ - else cpPlugins_Image_Demangle( \ - double, 4, o, f, r \ - ); \ - else r = std::string( #c ) + std::string( ": Image type." ); \ - } \ - else \ - r = \ - std::string( #c ) + \ - std::string( ": Image dimension not supported." ); \ - return( r ); \ - } -*/ - #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/CMakeLists.txt b/lib/cpPlugins/Plugins/CMakeLists.txt index 4bac628..6f972d2 100644 --- a/lib/cpPlugins/Plugins/CMakeLists.txt +++ b/lib/cpPlugins/Plugins/CMakeLists.txt @@ -4,33 +4,12 @@ SET(LIBRARY_NAME cpPlugins) ## = Source code = ## =============== - -#FILE(GLOB LIB_HEADERS_H "*.h") -#FILE(GLOB LIB_HEADERS_HPP "*.hpp") -#FILE(GLOB LIB_HEADERS_HXX "*.hxx") -#FILE(GLOB LIB_SOURCES_C "*.c") -#FILE(GLOB LIB_SOURCES_CPP "*.cpp") -#FILE(GLOB LIB_SOURCES_CXX "*.cxx") - -SET( - LIB_HEADERS_H - ImageReader.h - #ImageWriter.h - #MeshReader.h - #MeshWriter.h - #MarchingCubes.h - #OtsuThresholdImageFilter.h - ) -SET( - LIB_SOURCES_CXX - Host.cxx - ImageReader.cxx - #ImageWriter.cxx - #MeshReader.cxx - #MeshWriter.cxx - #MarchingCubes.cxx - #OtsuThresholdImageFilter.cxx - ) +FILE(GLOB LIB_HEADERS_H "*.h") +FILE(GLOB LIB_HEADERS_HPP "*.hpp") +FILE(GLOB LIB_HEADERS_HXX "*.hxx") +FILE(GLOB LIB_SOURCES_C "*.c") +FILE(GLOB LIB_SOURCES_CPP "*.cpp") +FILE(GLOB LIB_SOURCES_CXX "*.cxx") ## ===================== ## = Compilation rules = @@ -53,8 +32,6 @@ GENERATE_EXPORT_HEADER( TARGET_LINK_LIBRARIES( ${LIBRARY_NAME} cpPlugins_Interface - #${ITK_LIBRARIES} - #${VTK_LIBRARIES} ) ## ======================== diff --git a/lib/cpPlugins/Plugins/Host.cxx b/lib/cpPlugins/Plugins/Host.cxx index c74bd45..81488eb 100644 --- a/lib/cpPlugins/Plugins/Host.cxx +++ b/lib/cpPlugins/Plugins/Host.cxx @@ -1,41 +1,25 @@ #include #include -/* #include #include #include #include #include -*/ -/* - #include - #include - #include - #include -*/ -/// TODO: doc +#include +/// TODO: doc PLUMA_CONNECTOR bool connect( pluma::Host& host ) { using namespace cpPlugins::Plugins; host.add( new ImageReaderProvider( ) ); - /* host.add( new ImageWriterProvider( ) ); host.add( new MeshReaderProvider( ) ); host.add( new MeshWriterProvider( ) ); host.add( new MarchingCubesProvider( ) ); host.add( new OtsuThresholdImageFilterProvider( ) ); - */ - - /* - host.add( new ImageSeriesReaderProvider( ) ); - host.add( new MeshReaderProvider( ) ); - host.add( new PolyDataReaderProvider( ) ); - host.add( new RGBImageToHSVChannelsFilterProvider( ) ); - host.add( new RGBImageToYPbPrChannelsFilterProvider( ) ); - */ + host.add( new RGBImageToOtherChannelsFilterProvider( ) ); return( true ); } diff --git a/lib/cpPlugins/Plugins/ImageWriter.cxx b/lib/cpPlugins/Plugins/ImageWriter.cxx index 955d191..2a7154e 100644 --- a/lib/cpPlugins/Plugins/ImageWriter.cxx +++ b/lib/cpPlugins/Plugins/ImageWriter.cxx @@ -1,20 +1,6 @@ #include #include -#include - -#define ITK_MANUAL_INSTANTIATION -#include - -#include -#include -#include -#include -#include -#include -#include - -#undef ITK_MANUAL_INSTANTIATION #include // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.cxx index a23bc12..efc7d6a 100644 --- a/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.cxx @@ -1,20 +1,6 @@ #include #include -#include - -#define ITK_MANUAL_INSTANTIATION -#include - -#include -#include -#include -#include -#include -#include -#include - -#undef ITK_MANUAL_INSTANTIATION #include // ------------------------------------------------------------------------- @@ -29,7 +15,9 @@ OtsuThresholdImageFilter( ) this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); using namespace cpPlugins::Interface; - this->m_DefaultParameters.Configure( Parameters::Uint, "NumberOfHistogramBins" ); + this->m_DefaultParameters.Configure( + Parameters::Uint, "NumberOfHistogramBins" + ); this->m_DefaultParameters.Configure( Parameters::Real, "InsideValue" ); this->m_DefaultParameters.Configure( Parameters::Real, "OutsideValue" ); this->m_DefaultParameters.SetValueAsUint( "NumberOfHistogramBins", 100 ); @@ -120,53 +108,4 @@ _RealGD( itk::DataObject* image ) return( "OtsuThresholdImageFilter: output not correctly created." ); } -// ------------------------------------------------------------------------- -/* TODO - namespace cpPlugins - { - namespace Plugins - { - cpPlugins_Image_Demangle_Methods_Code_Only_Scalars( - OtsuThresholdImageFilter, _DemangleInput - ); - } - } - - // ------------------------------------------------------------------------- - template< class I > - std::string cpPlugins::Plugins::OtsuThresholdImageFilter:: - _DemangleInput( itk::DataObject* image ) - { - } - - // ------------------------------------------------------------------------- - template< class I, class O > - std::string cpPlugins::Plugins::OtsuThresholdImageFilter:: - _RealGD( itk::DataObject* image ) - { - typedef itk::OtsuThresholdImageFilter< I, O > _F; - typedef typename O::PixelType _OP; - - unsigned int bins = this->m_Parameters.GetValueAsUint( "NumberOfHistogramBins" ); - _OP in = _OP( this->m_Parameters.GetValueAsReal( "InsideValue" ) ); - _OP out = _OP( this->m_Parameters.GetValueAsReal( "OutsideValue" ) ); - - _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 - filter->SetInput( dynamic_cast< I* >( image ) ); - filter->SetNumberOfHistogramBins( bins ); - filter->SetInsideValue( in ); - filter->SetOutsideValue( out ); - filter->Update( ); - this->m_Outputs[ 0 ]->SetITKDataObject( filter->GetOutput( ) ); - - return( "" ); - } -*/ - // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.cxx b/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.cxx deleted file mode 100644 index 166dfee..0000000 --- a/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.cxx +++ /dev/null @@ -1,116 +0,0 @@ -#include -#include -#include -#include - -#define ITK_MANUAL_INSTANTIATION -#include -#include - -// ------------------------------------------------------------------------- -#define cpPlugins_RGB2HSV_Dimension( r, d, o, f ) \ - if( dynamic_cast< itk::ImageBase< d >* >( o ) != NULL ) \ - r = this->f< d >( ) - -// ------------------------------------------------------------------------- -#define cpPlugins_RGB2HSV_RGB( r, p, d, o, f ) \ - if( \ - dynamic_cast< itk::Image< itk::RGBPixel< p >, d >* >( o ) != NULL \ - ) \ - r = this->f< p, d >( ) - -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::RGBImageToHSVChannelsFilter:: -GetClassName( ) const -{ - return( "cpPlugins::Plugins::RGBImageToHSVChannelsFilter" ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Plugins::RGBImageToHSVChannelsFilter:: -RGBImageToHSVChannelsFilter( ) - : Superclass( ) -{ - this->SetNumberOfInputs( 1 ); - this->SetNumberOfOutputs( 3 ); - this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); - this->_MakeOutput< cpPlugins::Interface::Image >( 1 ); - this->_MakeOutput< cpPlugins::Interface::Image >( 2 ); - - this->m_DefaultParameters.Clear( ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Plugins::RGBImageToHSVChannelsFilter:: -~RGBImageToHSVChannelsFilter( ) -{ -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::RGBImageToHSVChannelsFilter:: -_GenerateData( ) -{ - itk::DataObject* o = this->_GetInput( 0 ); - - std::string r = "cpPlugins::Plugins::RGBImageToHSVChannelsFilter: itk::Image dimension not supported."; - cpPlugins_RGB2HSV_Dimension( r, 1, o, _GD0 ); - else cpPlugins_RGB2HSV_Dimension( r, 2, o, _GD0 ); - else cpPlugins_RGB2HSV_Dimension( r, 3, o, _GD0 ); - else cpPlugins_RGB2HSV_Dimension( r, 4, o, _GD0 ); - return( r ); -} - -// ------------------------------------------------------------------------- -template< unsigned int D > -std::string cpPlugins::Plugins::RGBImageToHSVChannelsFilter:: -_GD0( ) -{ - itk::ImageBase< D >* i = - dynamic_cast< itk::ImageBase< D >* >( this->_GetInput( 0 ) ); - - std::string r = "cpPlugins::Plugins::RGBImageToHSVChannelsFilter: itk::Image pixel type not supported"; - cpPlugins_RGB2HSV_RGB( r, char, D, i, _GD1 ); - else cpPlugins_RGB2HSV_RGB( r, short, D, i, _GD1 ); - else cpPlugins_RGB2HSV_RGB( r, int, D, i, _GD1 ); - else cpPlugins_RGB2HSV_RGB( r, long, D, i, _GD1 ); - else cpPlugins_RGB2HSV_RGB( r, unsigned char, D, i, _GD1 ); - else cpPlugins_RGB2HSV_RGB( r, unsigned short, D, i, _GD1 ); - else cpPlugins_RGB2HSV_RGB( r, unsigned int, D, i, _GD1 ); - else cpPlugins_RGB2HSV_RGB( r, unsigned long, D, i, _GD1 ); - else cpPlugins_RGB2HSV_RGB( r, float, D, i, _GD1 ); - else cpPlugins_RGB2HSV_RGB( r, double, D, i, _GD1 ); - return( r ); -} - -// ------------------------------------------------------------------------- -template< class P, unsigned int D > -std::string cpPlugins::Plugins::RGBImageToHSVChannelsFilter:: -_GD1( ) -{ - typedef itk::Image< itk::RGBPixel< P >, D > _TImage; - typedef itk::Image< P, D > _TChannel; - typedef cpPlugins::Extensions::Algorithms::RGBToHSVFunction< P > _TFunction; - typedef cpPlugins::Extensions::Algorithms:: - RGBImageToOtherChannelsFilter< _TImage, _TChannel, _TFunction > _TFilter; - - // Filter creation - _TFilter* filter = - dynamic_cast< _TFilter* >( this->m_RealProcessObject.GetPointer( ) ); - if( filter == NULL ) - { - this->m_RealProcessObject = _TFilter::New( ); - filter = - dynamic_cast< _TFilter* >( this->m_RealProcessObject.GetPointer( ) ); - - } // fi - filter->SetInput( dynamic_cast< _TImage* >( this->_GetInput( 0 ) ) ); - filter->Update( ); - - this->_SetOutput( 0, filter->GetChannel1( ) ); - this->_SetOutput( 1, filter->GetChannel2( ) ); - this->_SetOutput( 2, filter->GetChannel3( ) ); - - return( "" ); -} - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h b/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h deleted file mode 100644 index 5be93b2..0000000 --- a/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef __CPPLUGINS__PLUGINS__RGBIMAGETOHSVCHANNELSFILTER__H__ -#define __CPPLUGINS__PLUGINS__RGBIMAGETOHSVCHANNELSFILTER__H__ - -#include -#include - -namespace cpPlugins -{ - namespace Plugins - { - /** - */ - class cpPlugins_EXPORT RGBImageToHSVChannelsFilter - : public cpPlugins::Interface::ImageToImageFilter - { - public: - typedef RGBImageToHSVChannelsFilter Self; - typedef cpPlugins::Interface::ImageToImageFilter Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( - RGBImageToHSVChannelsFilter, - cpPluginsInterfaceImageToImageFilter - ); - - public: - virtual std::string GetClassName( ) const; - - protected: - RGBImageToHSVChannelsFilter( ); - virtual ~RGBImageToHSVChannelsFilter( ); - - virtual std::string _GenerateData( ); - - template< unsigned int D > - std::string _GD0( ); - - template< class P, unsigned int D > - std::string _GD1( ); - - private: - // Purposely not implemented - RGBImageToHSVChannelsFilter( const Self& ); - Self& operator=( const Self& ); - }; - - // --------------------------------------------------------------------- - CPPLUGINS_INHERIT_PROVIDER( RGBImageToHSVChannelsFilter ); - - } // ecapseman - -} // ecapseman - -#endif // __CPPLUGINS__PLUGINS__RGBIMAGETOHSVCHANNELSFILTER__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/RGBImageToOtherChannelsFilter.cxx b/lib/cpPlugins/Plugins/RGBImageToOtherChannelsFilter.cxx new file mode 100644 index 0000000..1a88201 --- /dev/null +++ b/lib/cpPlugins/Plugins/RGBImageToOtherChannelsFilter.cxx @@ -0,0 +1,134 @@ +#include +#include + +#include +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPlugins::Plugins::RGBImageToOtherChannelsFilter:: +RGBImageToOtherChannelsFilter( ) + : Superclass( ) +{ + typedef cpPlugins::Interface::Parameters TParameters; + + this->m_ClassName = "cpPlugins::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; +} + +// ------------------------------------------------------------------------- +cpPlugins::Plugins::RGBImageToOtherChannelsFilter:: +~RGBImageToOtherChannelsFilter( ) +{ +} + +// ------------------------------------------------------------------------- +#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::Plugins::RGBImageToOtherChannelsFilter:: +_GenerateData( ) +{ + cpPlugins::Interface::Image* image = + this->_Input< cpPlugins::Interface::Image >( 0 ); + if( image == NULL ) + return( "RGBImageToOtherChannelsFilter: No input image." ); + + 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 + ); + else r = "RGBImageToOtherChannelsFilter: Input image type not supported."; + return( r ); +} + +// ------------------------------------------------------------------------- +template< class I > +std::string cpPlugins::Plugins::RGBImageToOtherChannelsFilter:: +_DemangleOutput( itk::DataObject* image ) +{ + typedef typename I::PixelType _P; + + std::string outc = this->m_Parameters.GetValueAsString( "OutChannel" ); + std::string r = ""; + + using namespace cpExtensions::Algorithms; + if( outc == "HSV" ) + r = this->_RealGD< I, RGBToHSVFunction< _P > >( image ); + else if( outc == "YPbPr" ) + r = this->_RealGD< I, RGBToYPbPrFunction< _P > >( image ); + else if( outc == "Copy" ) + r = this->_RealGD< I, RGBExtractFunction< _P > >( image ); + else + r = + std::string( "RGBImageToOtherChannelsFilter: Conversor not available: " ) + + outc; + return( r ); +} + +// ------------------------------------------------------------------------- +template< class I, class C > +std::string cpPlugins::Plugins::RGBImageToOtherChannelsFilter:: +_RealGD( itk::DataObject* image ) +{ + typedef itk::Image< itk::RGBPixel< double >, I::ImageDimension > _O; + typedef + cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, _O, C > + _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 + filter->SetInput( dynamic_cast< I* >( image ) ); + filter->Update( ); + + // Connect output + cpPlugins::Interface::Image* out = + this->_Output< cpPlugins::Interface::Image >( 0 ); + if( out != NULL ) + { + out->SetITKImage< _O >( filter->GetOutput( ) ); + return( "" ); + } + else + return( "RGBImageToOtherChannelsFilter: output not correctly created." ); + + return( "" ); +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/RGBImageToOtherChannelsFilter.h b/lib/cpPlugins/Plugins/RGBImageToOtherChannelsFilter.h new file mode 100644 index 0000000..0ccb16c --- /dev/null +++ b/lib/cpPlugins/Plugins/RGBImageToOtherChannelsFilter.h @@ -0,0 +1,56 @@ +#ifndef __CPPLUGINS__PLUGINS__RGBIMAGETOOTHERCHANNELSFILTER__H__ +#define __CPPLUGINS__PLUGINS__RGBIMAGETOOTHERCHANNELSFILTER__H__ + +#include +#include + +namespace cpPlugins +{ + namespace Plugins + { + /** + */ + class cpPlugins_EXPORT RGBImageToOtherChannelsFilter + : public cpPlugins::Interface::ImageToImageFilter + { + public: + typedef RGBImageToOtherChannelsFilter Self; + typedef cpPlugins::Interface::ImageToImageFilter Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( + RGBImageToOtherChannelsFilter, + cpPluginsInterfaceImageToImageFilter + ); + + protected: + RGBImageToOtherChannelsFilter( ); + virtual ~RGBImageToOtherChannelsFilter( ); + + virtual std::string _GenerateData( ); + + template< class I > + inline std::string _DemangleOutput( itk::DataObject* image ); + + template< class I, class C > + inline std::string _RealGD( itk::DataObject* image ); + + private: + // Purposely not implemented + RGBImageToOtherChannelsFilter( const Self& ); + Self& operator=( const Self& ); + }; + + // --------------------------------------------------------------------- + CPPLUGINS_INHERIT_PROVIDER( RGBImageToOtherChannelsFilter ); + + } // ecapseman + +} // ecapseman + +#endif // __CPPLUGINS__PLUGINS__RGBIMAGETOOTHERCHANNELSFILTER__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/RGBImageToYPbPrChannelsFilter.cxx b/lib/cpPlugins/Plugins/RGBImageToYPbPrChannelsFilter.cxx deleted file mode 100644 index 85393b0..0000000 --- a/lib/cpPlugins/Plugins/RGBImageToYPbPrChannelsFilter.cxx +++ /dev/null @@ -1,136 +0,0 @@ -#include -#include -#include -#include - -#define ITK_MANUAL_INSTANTIATION -#include -#include - -// ------------------------------------------------------------------------- -#define cpPlugins_RGB2YPbPr_Dimension( r, d, o, f ) \ - if( dynamic_cast< itk::ImageBase< d >* >( o ) != NULL ) \ - r = this->f< d >( ) - -// ------------------------------------------------------------------------- -#define cpPlugins_RGB2YPbPr_RGB( r, p, d, o, f ) \ - if( \ - dynamic_cast< itk::Image< itk::RGBPixel< p >, d >* >( o ) != NULL \ - ) \ - r = this->f< p, d >( ) - -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::RGBImageToYPbPrChannelsFilter:: -GetClassName( ) const -{ - return( "cpPlugins::Plugins::RGBImageToYPbPrChannelsFilter" ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Plugins::RGBImageToYPbPrChannelsFilter:: -RGBImageToYPbPrChannelsFilter( ) - : Superclass( ) -{ - this->SetNumberOfInputs( 1 ); - this->SetNumberOfOutputs( 3 ); - this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); - this->_MakeOutput< cpPlugins::Interface::Image >( 1 ); - this->_MakeOutput< cpPlugins::Interface::Image >( 2 ); - - using namespace cpPlugins::Interface; - this->m_DefaultParameters.Configure( Parameters::String, "OutputPixelType" ); - this->m_DefaultParameters.SetValueAsString( "PixelType", "float" ); - this->m_Parameters = this->m_DefaultParameters; -} - -// ------------------------------------------------------------------------- -cpPlugins::Plugins::RGBImageToYPbPrChannelsFilter:: -~RGBImageToYPbPrChannelsFilter( ) -{ -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::RGBImageToYPbPrChannelsFilter:: -_GenerateData( ) -{ - itk::DataObject* o = this->_GetInput( 0 ); - - std::string r = "cpPlugins::Plugins::RGBImageToYPbPrChannelsFilter: itk::Image dimension not supported."; - cpPlugins_RGB2YPbPr_Dimension( r, 1, o, _GD0 ); - else cpPlugins_RGB2YPbPr_Dimension( r, 2, o, _GD0 ); - else cpPlugins_RGB2YPbPr_Dimension( r, 3, o, _GD0 ); - else cpPlugins_RGB2YPbPr_Dimension( r, 4, o, _GD0 ); - return( r ); -} - -// ------------------------------------------------------------------------- -template< unsigned int D > -std::string cpPlugins::Plugins::RGBImageToYPbPrChannelsFilter:: -_GD0( ) -{ - itk::ImageBase< D >* i = - dynamic_cast< itk::ImageBase< D >* >( this->_GetInput( 0 ) ); - - std::string r = "cpPlugins::Plugins::RGBImageToYPbPrChannelsFilter: itk::Image pixel type not supported"; - cpPlugins_RGB2YPbPr_RGB( r, char, D, i, _GD1 ); - else cpPlugins_RGB2YPbPr_RGB( r, short, D, i, _GD1 ); - else cpPlugins_RGB2YPbPr_RGB( r, int, D, i, _GD1 ); - else cpPlugins_RGB2YPbPr_RGB( r, long, D, i, _GD1 ); - else cpPlugins_RGB2YPbPr_RGB( r, unsigned char, D, i, _GD1 ); - else cpPlugins_RGB2YPbPr_RGB( r, unsigned short, D, i, _GD1 ); - else cpPlugins_RGB2YPbPr_RGB( r, unsigned int, D, i, _GD1 ); - else cpPlugins_RGB2YPbPr_RGB( r, unsigned long, D, i, _GD1 ); - else cpPlugins_RGB2YPbPr_RGB( r, float, D, i, _GD1 ); - else cpPlugins_RGB2YPbPr_RGB( r, double, D, i, _GD1 ); - return( r ); -} - -// ------------------------------------------------------------------------- -template< class P, unsigned int D > -std::string cpPlugins::Plugins::RGBImageToYPbPrChannelsFilter:: -_GD1( ) -{ - using namespace cpPlugins::Interface; - Parameters::TString pt = - this->m_Parameters.GetValueAsString( "OutputPixelType" ); - - std::string r = "cpPlugins::Plugins::RGBImageToYPbPrChannelsFilter: itk::Image output pixel type not supported"; - if( pt == "float" ) - r = this->_GD2< P, float, D >( ); - else if( pt == "double" ) - r = this->_GD2< P, double, D >( ); - return( r ); -} - -// ------------------------------------------------------------------------- -template< class P, class O, unsigned int D > -std::string cpPlugins::Plugins::RGBImageToYPbPrChannelsFilter:: -_GD2( ) -{ - typedef itk::Image< itk::RGBPixel< P >, D > _TImage; - typedef itk::Image< O, D > _TChannel; - typedef cpPlugins::Extensions::Algorithms::RGBToYPbPrFunction< O > _TFunction; - typedef cpPlugins::Extensions::Algorithms:: - RGBImageToOtherChannelsFilter< _TImage, _TChannel, _TFunction > _TFilter; - - // Filter creation - _TFilter* filter = - dynamic_cast< _TFilter* >( this->m_RealProcessObject.GetPointer( ) ); - if( filter == NULL ) - { - this->m_RealProcessObject = _TFilter::New( ); - filter = - dynamic_cast< _TFilter* >( this->m_RealProcessObject.GetPointer( ) ); - - } // fi - filter->SetInput( dynamic_cast< _TImage* >( this->_GetInput( 0 ) ) ); - filter->Update( ); - - this->_SetOutput( 0, filter->GetChannel1( ) ); - this->_SetOutput( 1, filter->GetChannel2( ) ); - this->_SetOutput( 2, filter->GetChannel3( ) ); - - return( "" ); -} - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/RGBImageToYPbPrChannelsFilter.h b/lib/cpPlugins/Plugins/RGBImageToYPbPrChannelsFilter.h deleted file mode 100644 index eb9c461..0000000 --- a/lib/cpPlugins/Plugins/RGBImageToYPbPrChannelsFilter.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef __CPPLUGINS__PLUGINS__RGBIMAGETOYPBPRCHANNELSFILTER__H__ -#define __CPPLUGINS__PLUGINS__RGBIMAGETOYPBPRCHANNELSFILTER__H__ - -#include -#include - -namespace cpPlugins -{ - namespace Plugins - { - /** - */ - class cpPlugins_EXPORT RGBImageToYPbPrChannelsFilter - : public cpPlugins::Interface::ImageToImageFilter - { - public: - typedef RGBImageToYPbPrChannelsFilter Self; - typedef cpPlugins::Interface::ImageToImageFilter Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( - RGBImageToYPbPrChannelsFilter, - cpPluginsInterfaceImageToImageFilter - ); - - public: - virtual std::string GetClassName( ) const; - - protected: - RGBImageToYPbPrChannelsFilter( ); - virtual ~RGBImageToYPbPrChannelsFilter( ); - - virtual std::string _GenerateData( ); - - template< unsigned int D > - std::string _GD0( ); - - template< class P, unsigned int D > - std::string _GD1( ); - - template< class P, class O, unsigned int D > - std::string _GD2( ); - - private: - // Purposely not implemented - RGBImageToYPbPrChannelsFilter( const Self& ); - Self& operator=( const Self& ); - }; - - // --------------------------------------------------------------------- - CPPLUGINS_INHERIT_PROVIDER( RGBImageToYPbPrChannelsFilter ); - - } // ecapseman - -} // ecapseman - -#endif // __CPPLUGINS__PLUGINS__RGBIMAGETOYPBPRCHANNELSFILTER__H__ - -// eof - $RCSfile$