From 683fd9cb190ab6835d4c8b58eb2823dd8fbe0b8e Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Fri, 28 Oct 2016 22:04:09 -0500 Subject: [PATCH] ... --- appli/bash/CreateDemanglers.cxx | 83 ++++++++++--------- lib/Instances/ImageFiltersBases.i | 1 + lib/cpPlugins/DataObjects/Image.cxx | 10 +-- lib/cpPlugins/DataObjects/Image.d | 9 ++ lib/cpPlugins/DataObjects/Mesh.cxx | 4 +- ...rvatureAnisotropicDiffusionImageFilter.cxx | 30 +++---- ...CurvatureAnisotropicDiffusionImageFilter.h | 4 +- plugins/CMakeLists.txt | 18 ++-- plugins/IO/ImageWriter.cxx | 12 +-- .../ImageArithmeticFilters/AddImageFilter.cxx | 40 +++++---- .../ImageArithmeticFilters/AddImageFilter.h | 11 ++- .../DivideImageFilter.cxx | 40 +++++---- .../DivideImageFilter.h | 11 ++- .../DivideOrZeroOutImageFilter.cxx | 44 +++++----- .../DivideOrZeroOutImageFilter.h | 11 ++- .../ImageArithmeticFilters.i | 16 ++++ .../MultiplyImageFilter.cxx | 40 +++++---- .../MultiplyImageFilter.h | 11 ++- .../NaryAddImageFilter.cxx | 49 +++++++++++ .../NaryAddImageFilter.h | 29 +++++++ .../ImageArithmeticFilters/PowImageFilter.cxx | 57 +++++++++---- .../ImageArithmeticFilters/PowImageFilter.h | 11 ++- .../SubtractImageFilter.cxx | 40 +++++---- .../SubtractImageFilter.h | 11 ++- .../ImageBooleanFilters/AndImageFilter.cxx | 28 ++++--- plugins/ImageBooleanFilters/AndImageFilter.h | 4 +- .../ImageBooleanFilters/ImageBooleanFilters.i | 12 +++ plugins/ImageBooleanFilters/OrImageFilter.cxx | 28 ++++--- plugins/ImageBooleanFilters/OrImageFilter.h | 4 +- .../ImageBooleanFilters/XorImageFilter.cxx | 28 ++++--- plugins/ImageBooleanFilters/XorImageFilter.h | 4 +- .../BinaryContourImageFilter.cxx | 4 +- .../SignedMaurerDistanceMapImageFilter.cxx | 4 +- .../ImageGenericFilters/ImageGenericFilters.i | 18 ++++ .../MinimumMaximumCalculator.cxx | 16 ++-- .../MinimumMaximumCalculator.h | 2 +- .../RegionOfInterestImageFilter.cxx | 19 +++-- .../RegionOfInterestImageFilter.h | 2 +- .../RescaleIntensityImageFilter.cxx | 10 ++- .../GulsunTekImageFilter.cxx | 19 +++-- .../GulsunTekImageFilter.h | 2 +- .../MultiScaleGaussianImageFilter.cxx | 32 +++---- .../MultiScaleGaussianImageFilter.h | 6 +- plugins/Widgets/LineWidget.cxx | 1 + plugins/Widgets/SplineWidget.cxx | 1 + 45 files changed, 540 insertions(+), 296 deletions(-) create mode 100644 plugins/ImageArithmeticFilters/ImageArithmeticFilters.i create mode 100644 plugins/ImageArithmeticFilters/NaryAddImageFilter.cxx create mode 100644 plugins/ImageArithmeticFilters/NaryAddImageFilter.h create mode 100644 plugins/ImageBooleanFilters/ImageBooleanFilters.i create mode 100644 plugins/ImageGenericFilters/ImageGenericFilters.i diff --git a/appli/bash/CreateDemanglers.cxx b/appli/bash/CreateDemanglers.cxx index 1b34b25..0b90d59 100644 --- a/appli/bash/CreateDemanglers.cxx +++ b/appli/bash/CreateDemanglers.cxx @@ -1,5 +1,7 @@ #include +#define MAX_NUMBER_OF_INPUTS 9 + // ------------------------------------------------------------------------- int main( int argc, char* argv[] ) { @@ -47,8 +49,8 @@ int main( int argc, char* argv[] ) // Expand data std::stringstream data; data - << "#ifndef __cpPlugins__Demangler__" << object_name << "__h__" << std::endl - << "#define __cpPlugins__Demangler__" << object_name << "__h__" << std::endl + << "#ifndef __cpPlugins__Demanglers__" << object_name << "__h__" << std::endl + << "#define __cpPlugins__Demanglers__" << object_name << "__h__" << std::endl << std::endl; for( auto cIt = commands.begin( ); cIt != commands.end( ); ++cIt ) @@ -60,38 +62,51 @@ int main( int argc, char* argv[] ) cpPlugins_bash::Expand( instances, definitions, commands, cIt->first ); TStrings toks; cpPlugins_bash::Tokenize( toks, cIt->first, "|" ); - if( toks.size( ) > 1 ) - { - data - << "#define cpPlugins_Demangle_" << object_name << "_" - << toks[ 0 ] << "( o, f, "; - for( unsigned int i = 1; i < toks.size( ); ++i ) - data << toks[ i ] << ", "; - data << "a ) \\"; - } - else - data - << "#define cpPlugins_Demangle_" << object_name << "_" - << toks[ 0 ] << "( o, f, a ) \\"; - data << std::endl; - std::string prefix = ""; - for( auto iIt = instances.begin( ); iIt != instances.end( ); ++iIt ) + for( unsigned int nIns = 1; nIns <= MAX_NUMBER_OF_INPUTS; ++nIns ) { - data - << " " << prefix - << "if( dynamic_cast< " << *iIt << "* >( o ) != NULL ) \\" - << std::endl - << " this->f( a dynamic_cast< " << *iIt << "* >( o ) ); \\" - << std::endl; - prefix = "else "; + if( toks.size( ) > 1 ) + { + data + << "#define cpPlugins_Demangle_" << object_name << "_" + << toks[ 0 ] << "_" << nIns << "( o, f"; + for( unsigned int i = 1; i < toks.size( ); ++i ) + data << ", " << toks[ i ]; + } + else + data + << "#define cpPlugins_Demangle_" << object_name << "_" + << toks[ 0 ] << "_" << nIns << "( o, f"; + + for( unsigned int i = 1; i < nIns; ++i ) + data << ", X" << i; + data << " ) \\"; + + data << std::endl; + std::string prefix = ""; + for( auto iIt = instances.begin( ); iIt != instances.end( ); ++iIt ) + { + data + << " " << prefix + << "if( dynamic_cast< " << *iIt << "* >( o ) != NULL ) \\" + << std::endl + << " this->f( dynamic_cast< " << *iIt << "* >( o )"; + + for( unsigned int i = 1; i < nIns; ++i ) + data << ", X" << i; + data + << " ); \\" + << std::endl; + prefix = "else "; + + } // rof + data << " " << prefix << std::endl << std::endl; } // rof - data << " " << prefix << std::endl << std::endl; } // rof data - << "#endif // __cpPlugins__Demangler__" << object_name << "__h__" + << "#endif // __cpPlugins__Demanglers__" << object_name << "__h__" << std::endl; if( !( cpPlugins_bash::Write( data.str( ), output_filename ) ) ) { @@ -100,20 +115,6 @@ int main( int argc, char* argv[] ) } // fi - - - /* TODO - TStrings instances; - cpPlugins_bash::Expand( instances, definitions, commands, "instances" ); - - // Build all instances - for( auto iIt = instances.begin( ); iIt != instances.end( ); ++iIt ) - { - std::cout << *iIt << std::endl; - - } // rof - */ - return( 0 ); } diff --git a/lib/Instances/ImageFiltersBases.i b/lib/Instances/ImageFiltersBases.i index 249c0a8..8b8805d 100644 --- a/lib/Instances/ImageFiltersBases.i +++ b/lib/Instances/ImageFiltersBases.i @@ -22,5 +22,6 @@ instances itk::ImageSource< itk::Image< itk::#matrices#< #real_types#, #process_ instances itk::ImageSource< itk::Image< itk::Offset< #process_dims# >, #process_dims# > > instances itk::#filters#< itk::Image< #in_scalar_pixels#, #process_dims# >, itk::Image< #out_scalar_pixels#, #process_dims# > > +instances itk::#filters#< itk::Image< itk::#color_pixels#< #in_scalar_pixels# >, #process_dims# >, itk::Image< itk::#color_pixels#< #out_scalar_pixels# >, #process_dims# > > ** eof - $RCSfile$ diff --git a/lib/cpPlugins/DataObjects/Image.cxx b/lib/cpPlugins/DataObjects/Image.cxx index 8378b40..77e70f6 100644 --- a/lib/cpPlugins/DataObjects/Image.cxx +++ b/lib/cpPlugins/DataObjects/Image.cxx @@ -16,8 +16,8 @@ void cpPlugins::DataObjects::Image:: SetITK( itk::LightObject* o ) { this->Superclass::SetITK( o ); - cpPlugins_Demangle_Image_VisualDims( o, _ITK_2_VTK_0, ) - cpPlugins_Demangle_Image_DiffTensors3D( o, _ITK_2_VTK_1, ) + cpPlugins_Demangle_Image_VisualDims_1( o, _ITK_2_VTK_0 ) + cpPlugins_Demangle_Image_DiffTensors3D_1( o, _ITK_2_VTK_1 ) { this->m_VTK = NULL; this->m_ITKvVTK = NULL; @@ -102,9 +102,9 @@ template< class _TImage > void cpPlugins::DataObjects::Image:: _ITK_2_VTK_0( _TImage* image ) { - cpPlugins_Demangle_Image_ScalarPixels( image, _ITK_2_VTK_1, _TImage::ImageDimension, ) - cpPlugins_Demangle_Image_ColorPixels( image, _ITK_2_VTK_1, _TImage::ImageDimension, ) - cpPlugins_Demangle_Image_VectorPixels( image, _ITK_2_VTK_1, _TImage::ImageDimension, ) + cpPlugins_Demangle_Image_ScalarPixels_1( image, _ITK_2_VTK_1, _TImage::ImageDimension ) + cpPlugins_Demangle_Image_ColorPixels_1( image, _ITK_2_VTK_1, _TImage::ImageDimension ) + cpPlugins_Demangle_Image_VectorPixels_1( image, _ITK_2_VTK_1, _TImage::ImageDimension ) { this->m_VTK = NULL; this->m_ITKvVTK = NULL; diff --git a/lib/cpPlugins/DataObjects/Image.d b/lib/cpPlugins/DataObjects/Image.d index 40ba788..0ed7696 100644 --- a/lib/cpPlugins/DataObjects/Image.d +++ b/lib/cpPlugins/DataObjects/Image.d @@ -11,4 +11,13 @@ ColorPixels|d itk::Image< itk::#color_pixels#< #scalar_pixels# >, d > VectorPixels|d itk::Image< itk::#vectors#< #real_types#, d >, d > DiffTensors3D itk::Image< itk::#diff_tensors#< #real_types# >, 3 > +IntPixels_AllDims itk::Image< #all_ints#, #process_dims# > +IntPixels_VisualDims itk::Image< #all_ints#, #process_dims# > +ScalarPixels_AllDims itk::Image< #scalar_pixels#, #process_dims# > +ScalarPixels_VisualDims itk::Image< #scalar_pixels#, #visual_dims# > +ColorPixels_AllDims itk::Image< itk::#color_pixels#< #scalar_pixels# >, #process_dims# > +ColorPixels_VisualDims itk::Image< itk::#color_pixels#< #scalar_pixels# >, #visual_dims# > +VectorPixels_AllDims itk::Image< itk::#vectors#< #real_types#, #process_dims# >, #process_dims# > +VectorPixels_VisualDims itk::Image< itk::#vectors#< #real_types#, #visual_dims# >, #visual_dims# > + ** eof - $RCSfile$ diff --git a/lib/cpPlugins/DataObjects/Mesh.cxx b/lib/cpPlugins/DataObjects/Mesh.cxx index e1ce594..ca2770b 100644 --- a/lib/cpPlugins/DataObjects/Mesh.cxx +++ b/lib/cpPlugins/DataObjects/Mesh.cxx @@ -12,8 +12,8 @@ void cpPlugins::DataObjects::Mesh:: SetITK( itk::LightObject* o ) { this->Superclass::SetITK( o ); - cpPlugins_Demangle_Mesh_Meshes( o, _ITK_2_VTK, 2, ) - cpPlugins_Demangle_Mesh_Meshes( o, _ITK_2_VTK, 3, ) + cpPlugins_Demangle_Mesh_Meshes_1( o, _ITK_2_VTK, 2 ) + cpPlugins_Demangle_Mesh_Meshes_1( o, _ITK_2_VTK, 3 ) { this->m_VTK = NULL; diff --git a/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.cxx b/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.cxx index 41e0c9c..d2f2aea 100644 --- a/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.cxx +++ b/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.cxx @@ -1,17 +1,20 @@ -#include +#include #include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +/* TODO + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +*/ // ------------------------------------------------------------------------- cpPluginsAnisotropicDiffusion::CurvatureAnisotropicDiffusionImageFilter:: @@ -43,9 +46,8 @@ void cpPluginsAnisotropicDiffusion::CurvatureAnisotropicDiffusionImageFilter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); - cpPlugins_Demangle_ImageScalars( o, _GD0, 2 ); - else cpPlugins_Demangle_ImageScalars( o, _GD0, 3 ); - else this->_Error( "No valid input image." ); + cpPlugins_Demangle_Image_ScalarPixels_VisualDims_1( o, _GD0 ) + this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- diff --git a/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.h b/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.h index 850c350..fb92cd1 100644 --- a/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.h +++ b/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.h @@ -1,7 +1,7 @@ #ifndef __cpPluginsAnisotropicDiffusion__CurvatureAnisotropicDiffusionImageFilter__h__ #define __cpPluginsAnisotropicDiffusion__CurvatureAnisotropicDiffusionImageFilter__h__ -#include +#include #include namespace cpPluginsAnisotropicDiffusion @@ -19,7 +19,7 @@ namespace cpPluginsAnisotropicDiffusion protected: template< class _TImage > - inline void _GD0( _TImage* image ); + inline void _GD0( _TImage* image ); }; } // ecapseman diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index c9cd7e3..e112573 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -4,25 +4,25 @@ SET( _dirlist - #AnisotropicDiffusion + AnisotropicDiffusion GenericFilters - #ImageArithmeticFilters - #ImageBooleanFilters + ImageArithmeticFilters + ImageBooleanFilters ImageDistanceMaps - #ImageGenericFilters - #ImageGradientFilters + ImageGenericFilters + ImageGradientFilters ImageMeshFilters ImageSources ImageThresholdFilters IO MeshFilters MeshSources - #Widgets + Widgets ) -#IF(ParabolicMorphology_LOADED) -# LIST(APPEND _dirlist ImageParaMorphologyFilters) -#ENDIF(ParabolicMorphology_LOADED) +IF(ParabolicMorphology_LOADED) + LIST(APPEND _dirlist ImageParaMorphologyFilters) +ENDIF(ParabolicMorphology_LOADED) ## =============================== ## == Build each plugin library == diff --git a/plugins/IO/ImageWriter.cxx b/plugins/IO/ImageWriter.cxx index 94a822b..8fcf08e 100644 --- a/plugins/IO/ImageWriter.cxx +++ b/plugins/IO/ImageWriter.cxx @@ -118,8 +118,8 @@ void cpPluginsIO::ImageWriter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); - cpPlugins_Demangle_Image_ProcessDims( o, _GD0, ) - cpPlugins_Demangle_Image_DiffTensors3D( o, _GD1, ) + cpPlugins_Demangle_Image_ProcessDims_1( o, _GD0 ) + cpPlugins_Demangle_Image_DiffTensors3D_1( o, _GD1 ) this->_Error( "Invalid input image dimension." ); } @@ -128,10 +128,10 @@ template< class _TImage > void cpPluginsIO::ImageWriter:: _GD0( _TImage* image ) { - cpPlugins_Demangle_Image_ScalarPixels( image, _GD1, _TImage::ImageDimension, ) - cpPlugins_Demangle_Image_ComplexPixels( image, _GD1, _TImage::ImageDimension, ) - cpPlugins_Demangle_Image_ColorPixels( image, _GD1, _TImage::ImageDimension, ) - cpPlugins_Demangle_Image_VectorPixels( image, _GD1, _TImage::ImageDimension, ) + cpPlugins_Demangle_Image_ScalarPixels_1( image, _GD1, _TImage::ImageDimension ) + cpPlugins_Demangle_Image_ComplexPixels_1( image, _GD1, _TImage::ImageDimension ) + cpPlugins_Demangle_Image_ColorPixels_1( image, _GD1, _TImage::ImageDimension ) + cpPlugins_Demangle_Image_VectorPixels_1( image, _GD1, _TImage::ImageDimension ) this->_Error( "Invalid input image pixel type." ); } diff --git a/plugins/ImageArithmeticFilters/AddImageFilter.cxx b/plugins/ImageArithmeticFilters/AddImageFilter.cxx index a0398d6..35f64ec 100644 --- a/plugins/ImageArithmeticFilters/AddImageFilter.cxx +++ b/plugins/ImageArithmeticFilters/AddImageFilter.cxx @@ -1,17 +1,18 @@ -#include +#include #include +#include #include -#include // ------------------------------------------------------------------------- cpPluginsImageArithmeticFilters::AddImageFilter:: AddImageFilter( ) : Superclass( ) { - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false ); - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", true, false ); - this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); + typedef cpPlugins::DataObjects::Image _TImage; + this->_ConfigureInput< _TImage >( "Input1", true, false ); + this->_ConfigureInput< _TImage >( "Input2", true, false ); + this->_ConfigureOutput< _TImage >( "Output" ); } // ------------------------------------------------------------------------- @@ -24,26 +25,33 @@ cpPluginsImageArithmeticFilters::AddImageFilter:: void cpPluginsImageArithmeticFilters::AddImageFilter:: _GenerateData( ) { - auto o = this->GetInputData( "Input0" ); - cpPlugins_Demangle_ImageIntegers_Dims( o, _GD0 ); - else this->_Error( "Invalid input image." ); + auto o = this->GetInputData( "Input1" ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image (0)." ); } // ------------------------------------------------------------------------- -template< class _TImage > +template< class _TInput1 > void cpPluginsImageArithmeticFilters::AddImageFilter:: -_GD0( _TImage* image0 ) +_GD0( _TInput1* input1 ) { - typedef itk::AddImageFilter< _TImage, _TImage > _TFilter; - - auto image1 = this->GetInputData< _TImage >( "Input1" ); - if( image1 == NULL ) + auto input2 = this->GetInputData< _TInput1 >( "Input2" ); + if( input2 == NULL ) this->_Error( "Incompatible second input image." ); + this->_GD1( input2, input1 ); +} + +// ------------------------------------------------------------------------- +template< class _TInput2, class _TInput1 > +void cpPluginsImageArithmeticFilters::AddImageFilter:: +_GD1( _TInput2* input2, _TInput1* input1 ) +{ + typedef itk::AddImageFilter< _TInput1, _TInput2, _TInput1 > _TFilter; // Configure filter auto filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( 0, image0 ); - filter->SetInput( 1, image1 ); + filter->SetInput1( input1 ); + filter->SetInput2( input2 ); filter->Update( ); // Connect output diff --git a/plugins/ImageArithmeticFilters/AddImageFilter.h b/plugins/ImageArithmeticFilters/AddImageFilter.h index 7f48c52..ad3222d 100644 --- a/plugins/ImageArithmeticFilters/AddImageFilter.h +++ b/plugins/ImageArithmeticFilters/AddImageFilter.h @@ -1,7 +1,7 @@ #ifndef __cpPluginsImageArithmeticFilters__AddImageFilter__h__ #define __cpPluginsImageArithmeticFilters__AddImageFilter__h__ -#include +#include #include namespace cpPluginsImageArithmeticFilters @@ -14,12 +14,15 @@ namespace cpPluginsImageArithmeticFilters cpPluginsObject( AddImageFilter, cpPlugins::BaseObjects::ProcessObject, - ImageBooleanFilters + ImageArithmeticFilters ); protected: - template< class _TImage > - inline void _GD0( _TImage* image0 ); + template< class _TInput1 > + inline void _GD0( _TInput1* input1 ); + + template< class _TInput2, class _TInput1 > + inline void _GD1( _TInput2* input2, _TInput1* input1 ); }; } // ecapseman diff --git a/plugins/ImageArithmeticFilters/DivideImageFilter.cxx b/plugins/ImageArithmeticFilters/DivideImageFilter.cxx index a802667..4c36ae2 100644 --- a/plugins/ImageArithmeticFilters/DivideImageFilter.cxx +++ b/plugins/ImageArithmeticFilters/DivideImageFilter.cxx @@ -1,17 +1,18 @@ -#include +#include #include +#include #include -#include // ------------------------------------------------------------------------- cpPluginsImageArithmeticFilters::DivideImageFilter:: DivideImageFilter( ) : Superclass( ) { - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false ); - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", true, false ); - this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); + typedef cpPlugins::DataObjects::Image _TImage; + this->_ConfigureInput< _TImage >( "Input1", true, false ); + this->_ConfigureInput< _TImage >( "Input2", true, false ); + this->_ConfigureOutput< _TImage >( "Output" ); } // ------------------------------------------------------------------------- @@ -24,26 +25,33 @@ cpPluginsImageArithmeticFilters::DivideImageFilter:: void cpPluginsImageArithmeticFilters::DivideImageFilter:: _GenerateData( ) { - auto o = this->GetInputData( "Input0" ); - cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 ); - else this->_Error( "Invalid input image." ); + auto o = this->GetInputData( "Input1" ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image (0)." ); } // ------------------------------------------------------------------------- -template< class _TImage > +template< class _TInput1 > void cpPluginsImageArithmeticFilters::DivideImageFilter:: -_GD0( _TImage* image0 ) +_GD0( _TInput1* input1 ) { - typedef itk::DivideImageFilter< _TImage, _TImage, _TImage > _TFilter; - - auto image1 = this->GetInputData< _TImage >( "Input1" ); - if( image1 == NULL ) + auto input2 = this->GetInputData< _TInput1 >( "Input2" ); + if( input2 == NULL ) this->_Error( "Incompatible second input image." ); + this->_GD1( input2, input1 ); +} + +// ------------------------------------------------------------------------- +template< class _TInput2, class _TInput1 > +void cpPluginsImageArithmeticFilters::DivideImageFilter:: +_GD1( _TInput2* input2, _TInput1* input1 ) +{ + typedef itk::DivideImageFilter< _TInput1, _TInput2, _TInput1 > _TFilter; // Configure filter auto filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( 0, image0 ); - filter->SetInput( 1, image1 ); + filter->SetInput1( input1 ); + filter->SetInput2( input2 ); filter->Update( ); // Connect output diff --git a/plugins/ImageArithmeticFilters/DivideImageFilter.h b/plugins/ImageArithmeticFilters/DivideImageFilter.h index 7825c8c..c222bf8 100644 --- a/plugins/ImageArithmeticFilters/DivideImageFilter.h +++ b/plugins/ImageArithmeticFilters/DivideImageFilter.h @@ -1,7 +1,7 @@ #ifndef __cpPluginsImageArithmeticFilters__DivideImageFilter__h__ #define __cpPluginsImageArithmeticFilters__DivideImageFilter__h__ -#include +#include #include namespace cpPluginsImageArithmeticFilters @@ -14,12 +14,15 @@ namespace cpPluginsImageArithmeticFilters cpPluginsObject( DivideImageFilter, cpPlugins::BaseObjects::ProcessObject, - ImageBooleanFilters + ImageArithmeticFilters ); protected: - template< class _TImage > - inline void _GD0( _TImage* image0 ); + template< class _TInput1 > + inline void _GD0( _TInput1* input1 ); + + template< class _TInput2, class _TInput1 > + inline void _GD1( _TInput2* input2, _TInput1* input1 ); }; } // ecapseman diff --git a/plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.cxx b/plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.cxx index 4a80569..959eb02 100644 --- a/plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.cxx +++ b/plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.cxx @@ -1,20 +1,18 @@ -#include +#include #include +#include #include -#include // ------------------------------------------------------------------------- cpPluginsImageArithmeticFilters::DivideOrZeroOutImageFilter:: DivideOrZeroOutImageFilter( ) : Superclass( ) { - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false ); - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", true, false ); - this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); - - this->m_Parameters.ConfigureAsReal( "Threshold" ); - this->m_Parameters.SetReal( "Threshold", 1e-10 ); + typedef cpPlugins::DataObjects::Image _TImage; + this->_ConfigureInput< _TImage >( "Input1", true, false ); + this->_ConfigureInput< _TImage >( "Input2", true, false ); + this->_ConfigureOutput< _TImage >( "Output" ); } // ------------------------------------------------------------------------- @@ -27,27 +25,33 @@ cpPluginsImageArithmeticFilters::DivideOrZeroOutImageFilter:: void cpPluginsImageArithmeticFilters::DivideOrZeroOutImageFilter:: _GenerateData( ) { - auto o = this->GetInputData( "Input0" ); - cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 ); - else this->_Error( "Invalid input image." ); + auto o = this->GetInputData( "Input1" ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image (0)." ); } // ------------------------------------------------------------------------- -template< class _TImage > +template< class _TInput1 > void cpPluginsImageArithmeticFilters::DivideOrZeroOutImageFilter:: -_GD0( _TImage* image0 ) +_GD0( _TInput1* input1 ) { - typedef itk::DivideOrZeroOutImageFilter< _TImage, _TImage, _TImage > _TFilter; - - auto image1 = this->GetInputData< _TImage >( "Input1" ); - if( image1 == NULL ) + auto input2 = this->GetInputData< _TInput1 >( "Input2" ); + if( input2 == NULL ) this->_Error( "Incompatible second input image." ); + this->_GD1( input2, input1 ); +} + +// ------------------------------------------------------------------------- +template< class _TInput2, class _TInput1 > +void cpPluginsImageArithmeticFilters::DivideOrZeroOutImageFilter:: +_GD1( _TInput2* input2, _TInput1* input1 ) +{ + typedef itk::DivideOrZeroOutImageFilter< _TInput1, _TInput2, _TInput1 > _TFilter; // Configure filter auto filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( 0, image0 ); - filter->SetInput( 1, image1 ); - filter->SetThreshold( this->m_Parameters.GetReal( "Threshold" ) ); + filter->SetInput1( input1 ); + filter->SetInput2( input2 ); filter->Update( ); // Connect output diff --git a/plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.h b/plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.h index e7f6ff0..e2a43a5 100644 --- a/plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.h +++ b/plugins/ImageArithmeticFilters/DivideOrZeroOutImageFilter.h @@ -1,7 +1,7 @@ #ifndef __cpPluginsImageArithmeticFilters__DivideOrZeroOutImageFilter__h__ #define __cpPluginsImageArithmeticFilters__DivideOrZeroOutImageFilter__h__ -#include +#include #include namespace cpPluginsImageArithmeticFilters @@ -14,12 +14,15 @@ namespace cpPluginsImageArithmeticFilters cpPluginsObject( DivideOrZeroOutImageFilter, cpPlugins::BaseObjects::ProcessObject, - ImageBooleanFilters + ImageArithmeticFilters ); protected: - template< class _TImage > - inline void _GD0( _TImage* image0 ); + template< class _TInput1 > + inline void _GD0( _TInput1* input1 ); + + template< class _TInput2, class _TInput1 > + inline void _GD1( _TInput2* input2, _TInput1* input1 ); }; } // ecapseman diff --git a/plugins/ImageArithmeticFilters/ImageArithmeticFilters.i b/plugins/ImageArithmeticFilters/ImageArithmeticFilters.i new file mode 100644 index 0000000..f998723 --- /dev/null +++ b/plugins/ImageArithmeticFilters/ImageArithmeticFilters.i @@ -0,0 +1,16 @@ +header #define ITK_MANUAL_INSTANTIATION + +define filters=Add;Subtract;Multiply;Divide;DivideOrZeroOut;Pow +define functors=Add2;Sub2;Mult;Div;DivideOrZeroOut;Pow + +tinclude itkBinaryFunctorImageFilter:h|hxx +tinclude itkNaryFunctorImageFilter:h|hxx + +cinclude itk#filters#ImageFilter.h +cinclude itkNaryAddImageFilter.h + +instances itk::BinaryFunctorImageFilter< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #scalar_pixels#, #process_dims# >, itk::Functor::#functors#< #scalar_pixels#, #scalar_pixels#, #scalar_pixels# > > + +instances itk::NaryFunctorImageFilter< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #scalar_pixels#, #process_dims# >, itk::Functor::Add1< #scalar_pixels#, #scalar_pixels# > > + +** eof - $RCSfile$ diff --git a/plugins/ImageArithmeticFilters/MultiplyImageFilter.cxx b/plugins/ImageArithmeticFilters/MultiplyImageFilter.cxx index 3736968..1f83962 100644 --- a/plugins/ImageArithmeticFilters/MultiplyImageFilter.cxx +++ b/plugins/ImageArithmeticFilters/MultiplyImageFilter.cxx @@ -1,17 +1,18 @@ -#include +#include #include +#include #include -#include // ------------------------------------------------------------------------- cpPluginsImageArithmeticFilters::MultiplyImageFilter:: MultiplyImageFilter( ) : Superclass( ) { - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false ); - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", true, false ); - this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); + typedef cpPlugins::DataObjects::Image _TImage; + this->_ConfigureInput< _TImage >( "Input1", true, false ); + this->_ConfigureInput< _TImage >( "Input2", true, false ); + this->_ConfigureOutput< _TImage >( "Output" ); } // ------------------------------------------------------------------------- @@ -24,26 +25,33 @@ cpPluginsImageArithmeticFilters::MultiplyImageFilter:: void cpPluginsImageArithmeticFilters::MultiplyImageFilter:: _GenerateData( ) { - auto o = this->GetInputData( "Input0" ); - cpPlugins_Demangle_ImageIntegers_Dims( o, _GD0 ); - else this->_Error( "Invalid input image." ); + auto o = this->GetInputData( "Input1" ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image (0)." ); } // ------------------------------------------------------------------------- -template< class _TImage > +template< class _TInput1 > void cpPluginsImageArithmeticFilters::MultiplyImageFilter:: -_GD0( _TImage* image0 ) +_GD0( _TInput1* input1 ) { - typedef itk::MultiplyImageFilter< _TImage, _TImage > _TFilter; - - auto image1 = this->GetInputData< _TImage >( "Input1" ); - if( image1 == NULL ) + auto input2 = this->GetInputData< _TInput1 >( "Input2" ); + if( input2 == NULL ) this->_Error( "Incompatible second input image." ); + this->_GD1( input2, input1 ); +} + +// ------------------------------------------------------------------------- +template< class _TInput2, class _TInput1 > +void cpPluginsImageArithmeticFilters::MultiplyImageFilter:: +_GD1( _TInput2* input2, _TInput1* input1 ) +{ + typedef itk::MultiplyImageFilter< _TInput1, _TInput2, _TInput1 > _TFilter; // Configure filter auto filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( 0, image0 ); - filter->SetInput( 1, image1 ); + filter->SetInput1( input1 ); + filter->SetInput2( input2 ); filter->Update( ); // Connect output diff --git a/plugins/ImageArithmeticFilters/MultiplyImageFilter.h b/plugins/ImageArithmeticFilters/MultiplyImageFilter.h index 8614096..747bf6b 100644 --- a/plugins/ImageArithmeticFilters/MultiplyImageFilter.h +++ b/plugins/ImageArithmeticFilters/MultiplyImageFilter.h @@ -1,7 +1,7 @@ #ifndef __cpPluginsImageArithmeticFilters__MultiplyImageFilter__h__ #define __cpPluginsImageArithmeticFilters__MultiplyImageFilter__h__ -#include +#include #include namespace cpPluginsImageArithmeticFilters @@ -14,12 +14,15 @@ namespace cpPluginsImageArithmeticFilters cpPluginsObject( MultiplyImageFilter, cpPlugins::BaseObjects::ProcessObject, - ImageBooleanFilters + ImageArithmeticFilters ); protected: - template< class _TImage > - inline void _GD0( _TImage* image0 ); + template< class _TInput1 > + inline void _GD0( _TInput1* input1 ); + + template< class _TInput2, class _TInput1 > + inline void _GD1( _TInput2* input2, _TInput1* input1 ); }; } // ecapseman diff --git a/plugins/ImageArithmeticFilters/NaryAddImageFilter.cxx b/plugins/ImageArithmeticFilters/NaryAddImageFilter.cxx new file mode 100644 index 0000000..bc48345 --- /dev/null +++ b/plugins/ImageArithmeticFilters/NaryAddImageFilter.cxx @@ -0,0 +1,49 @@ +#include +#include +#include + +#include + +// ------------------------------------------------------------------------- +cpPluginsImageArithmeticFilters::NaryAddImageFilter:: +NaryAddImageFilter( ) + : Superclass( ) +{ + typedef cpPlugins::DataObjects::Image _TImage; + this->_ConfigureInput< _TImage >( "Inputs", true, true ); + this->_ConfigureOutput< _TImage >( "Output" ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageArithmeticFilters::NaryAddImageFilter:: +~NaryAddImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsImageArithmeticFilters::NaryAddImageFilter:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Inputs", 0 ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image (0)." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpPluginsImageArithmeticFilters::NaryAddImageFilter:: +_GD0( _TImage* image1 ) +{ + typedef itk::NaryAddImageFilter< _TImage, _TImage > _TFilter; + + // Configure filter + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( 0, image1 ); + unsigned int nInputs = this->GetInputSize( "Inputs" ); + for( unsigned int i = 1; i < nInputs; ++i ) + filter->SetInput( i, this->GetInputData< _TImage >( "Inputs", i ) ); + filter->Update( ); + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/ImageArithmeticFilters/NaryAddImageFilter.h b/plugins/ImageArithmeticFilters/NaryAddImageFilter.h new file mode 100644 index 0000000..dc104a9 --- /dev/null +++ b/plugins/ImageArithmeticFilters/NaryAddImageFilter.h @@ -0,0 +1,29 @@ +#ifndef __cpPluginsImageArithmeticFilters__NaryAddImageFilter__h__ +#define __cpPluginsImageArithmeticFilters__NaryAddImageFilter__h__ + +#include +#include + +namespace cpPluginsImageArithmeticFilters +{ + /** + */ + class cpPluginsImageArithmeticFilters_EXPORT NaryAddImageFilter + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + NaryAddImageFilter, + cpPlugins::BaseObjects::ProcessObject, + ImageArithmeticFilters + ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* image1 ); + }; + +} // ecapseman + +#endif // __cpPluginsImageArithmeticFilters__NaryAddImageFilter__h__ + +// eof - $RCSfile$ diff --git a/plugins/ImageArithmeticFilters/PowImageFilter.cxx b/plugins/ImageArithmeticFilters/PowImageFilter.cxx index f0b4c8e..62c2a85 100644 --- a/plugins/ImageArithmeticFilters/PowImageFilter.cxx +++ b/plugins/ImageArithmeticFilters/PowImageFilter.cxx @@ -1,17 +1,18 @@ -#include +#include #include +#include #include -#include // ------------------------------------------------------------------------- cpPluginsImageArithmeticFilters::PowImageFilter:: PowImageFilter( ) : Superclass( ) { - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false ); - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", false, false ); - this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); + typedef cpPlugins::DataObjects::Image _TImage; + this->_ConfigureInput< _TImage >( "Input1", true, false ); + this->_ConfigureInput< _TImage >( "Input2", true, false ); + this->_ConfigureOutput< _TImage >( "Output" ); this->m_Parameters.ConfigureAsReal( "Constant" ); this->m_Parameters.SetReal( "Constant", 1 ); @@ -27,26 +28,33 @@ cpPluginsImageArithmeticFilters::PowImageFilter:: void cpPluginsImageArithmeticFilters::PowImageFilter:: _GenerateData( ) { - auto o = this->GetInputData( "Input0" ); - cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 ); - else this->_Error( "Invalid input image." ); + auto o = this->GetInputData( "Input1" ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image (0)." ); } // ------------------------------------------------------------------------- -template< class _TImage > +template< class _TInput1 > void cpPluginsImageArithmeticFilters::PowImageFilter:: -_GD0( _TImage* image0 ) +_GD0( _TInput1* input1 ) { - typedef itk::PowImageFilter< _TImage, _TImage > _TFilter; + auto input2 = this->GetInputData< _TInput1 >( "Input2" ); + if( input2 == NULL ) + this->_Error( "Incompatible second input image." ); + this->_GD1( input2, input1 ); +} + +// ------------------------------------------------------------------------- +template< class _TInput2, class _TInput1 > +void cpPluginsImageArithmeticFilters::PowImageFilter:: +_GD1( _TInput2* input2, _TInput1* input1 ) +{ + typedef itk::PowImageFilter< _TInput1, _TInput2, _TInput1 > _TFilter; // Configure filter auto filter = this->_CreateITK< _TFilter >( ); - filter->SetInput1( image0 ); - auto image1 = this->GetInputData< _TImage >( "Input1" ); - if( image1 == NULL ) - filter->SetConstant( this->m_Parameters.GetReal( "Constant" ) ); - else - filter->SetInput2( image1 ); + filter->SetInput1( input1 ); + filter->SetInput2( input2 ); filter->Update( ); // Connect output @@ -54,3 +62,18 @@ _GD0( _TImage* image0 ) } // eof - $RCSfile$ + +/* TODO + filter->SetInput1( image0 ); + auto image1 = this->GetInputData< _TImage >( "Input1" ); + if( image1 == NULL ) + filter->SetConstant( this->m_Parameters.GetReal( "Constant" ) ); + else + filter->SetInput2( image1 ); + filter->Update( ); + + // Connect output + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +*/ + +// eof - $RCSfile$ diff --git a/plugins/ImageArithmeticFilters/PowImageFilter.h b/plugins/ImageArithmeticFilters/PowImageFilter.h index 4882c6a..53de79a 100644 --- a/plugins/ImageArithmeticFilters/PowImageFilter.h +++ b/plugins/ImageArithmeticFilters/PowImageFilter.h @@ -1,7 +1,7 @@ #ifndef __cpPluginsImageArithmeticFilters__PowImageFilter__h__ #define __cpPluginsImageArithmeticFilters__PowImageFilter__h__ -#include +#include #include namespace cpPluginsImageArithmeticFilters @@ -14,12 +14,15 @@ namespace cpPluginsImageArithmeticFilters cpPluginsObject( PowImageFilter, cpPlugins::BaseObjects::ProcessObject, - ImageBooleanFilters + ImageArithmeticFilters ); protected: - template< class _TImage > - inline void _GD0( _TImage* image0 ); + template< class _TInput1 > + inline void _GD0( _TInput1* input1 ); + + template< class _TInput2, class _TInput1 > + inline void _GD1( _TInput2* input2, _TInput1* input1 ); }; } // ecapseman diff --git a/plugins/ImageArithmeticFilters/SubtractImageFilter.cxx b/plugins/ImageArithmeticFilters/SubtractImageFilter.cxx index 0b0c1cf..5081d54 100644 --- a/plugins/ImageArithmeticFilters/SubtractImageFilter.cxx +++ b/plugins/ImageArithmeticFilters/SubtractImageFilter.cxx @@ -1,17 +1,18 @@ -#include +#include #include +#include #include -#include // ------------------------------------------------------------------------- cpPluginsImageArithmeticFilters::SubtractImageFilter:: SubtractImageFilter( ) : Superclass( ) { - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false ); - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", true, false ); - this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); + typedef cpPlugins::DataObjects::Image _TImage; + this->_ConfigureInput< _TImage >( "Input1", true, false ); + this->_ConfigureInput< _TImage >( "Input2", true, false ); + this->_ConfigureOutput< _TImage >( "Output" ); } // ------------------------------------------------------------------------- @@ -24,26 +25,33 @@ cpPluginsImageArithmeticFilters::SubtractImageFilter:: void cpPluginsImageArithmeticFilters::SubtractImageFilter:: _GenerateData( ) { - auto o = this->GetInputData( "Input0" ); - cpPlugins_Demangle_ImageIntegers_Dims( o, _GD0 ); - else this->_Error( "Invalid input image." ); + auto o = this->GetInputData( "Input1" ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image (0)." ); } // ------------------------------------------------------------------------- -template< class _TImage > +template< class _TInput1 > void cpPluginsImageArithmeticFilters::SubtractImageFilter:: -_GD0( _TImage* image0 ) +_GD0( _TInput1* input1 ) { - typedef itk::SubtractImageFilter< _TImage, _TImage > _TFilter; - - auto image1 = this->GetInputData< _TImage >( "Input1" ); - if( image1 == NULL ) + auto input2 = this->GetInputData< _TInput1 >( "Input2" ); + if( input2 == NULL ) this->_Error( "Incompatible second input image." ); + this->_GD1( input2, input1 ); +} + +// ------------------------------------------------------------------------- +template< class _TInput2, class _TInput1 > +void cpPluginsImageArithmeticFilters::SubtractImageFilter:: +_GD1( _TInput2* input2, _TInput1* input1 ) +{ + typedef itk::SubtractImageFilter< _TInput1, _TInput2, _TInput1 > _TFilter; // Configure filter auto filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( 0, image0 ); - filter->SetInput( 1, image1 ); + filter->SetInput1( input1 ); + filter->SetInput2( input2 ); filter->Update( ); // Connect output diff --git a/plugins/ImageArithmeticFilters/SubtractImageFilter.h b/plugins/ImageArithmeticFilters/SubtractImageFilter.h index f8e529f..c097aa8 100644 --- a/plugins/ImageArithmeticFilters/SubtractImageFilter.h +++ b/plugins/ImageArithmeticFilters/SubtractImageFilter.h @@ -1,7 +1,7 @@ #ifndef __cpPluginsImageArithmeticFilters__SubtractImageFilter__h__ #define __cpPluginsImageArithmeticFilters__SubtractImageFilter__h__ -#include +#include #include namespace cpPluginsImageArithmeticFilters @@ -14,12 +14,15 @@ namespace cpPluginsImageArithmeticFilters cpPluginsObject( SubtractImageFilter, cpPlugins::BaseObjects::ProcessObject, - ImageBooleanFilters + ImageArithmeticFilters ); protected: - template< class _TImage > - inline void _GD0( _TImage* image0 ); + template< class _TInput1 > + inline void _GD0( _TInput1* input1 ); + + template< class _TInput2, class _TInput1 > + inline void _GD1( _TInput2* input2, _TInput1* input1 ); }; } // ecapseman diff --git a/plugins/ImageBooleanFilters/AndImageFilter.cxx b/plugins/ImageBooleanFilters/AndImageFilter.cxx index 1307919..27194ae 100644 --- a/plugins/ImageBooleanFilters/AndImageFilter.cxx +++ b/plugins/ImageBooleanFilters/AndImageFilter.cxx @@ -1,17 +1,19 @@ -#include +#include #include +#include #include -#include // ------------------------------------------------------------------------- cpPluginsImageBooleanFilters::AndImageFilter:: AndImageFilter( ) : Superclass( ) { - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false ); - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", true, false ); - this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); + typedef cpPlugins::DataObjects::Image _TImage; + + this->_ConfigureInput< _TImage >( "Input1", true, false ); + this->_ConfigureInput< _TImage >( "Input2", true, false ); + this->_ConfigureOutput< _TImage >( "Output" ); } // ------------------------------------------------------------------------- @@ -24,26 +26,26 @@ cpPluginsImageBooleanFilters::AndImageFilter:: void cpPluginsImageBooleanFilters::AndImageFilter:: _GenerateData( ) { - auto o = this->GetInputData( "Input0" ); - cpPlugins_Demangle_ImageIntegers_Dims( o, _GD0 ); - else this->_Error( "Invalid input image." ); + auto o = this->GetInputData( "Input1" ); + cpPlugins_Demangle_Image_IntPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > void cpPluginsImageBooleanFilters::AndImageFilter:: -_GD0( _TImage* image0 ) +_GD0( _TImage* image1 ) { typedef itk::AndImageFilter< _TImage, _TImage > _TFilter; - auto image1 = this->GetInputData< _TImage >( "Input1" ); - if( image1 == NULL ) + auto image2 = this->GetInputData< _TImage >( "Input2" ); + if( image2 == NULL ) this->_Error( "Incompatible second input image." ); // Configure filter auto filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( 0, image0 ); - filter->SetInput( 1, image1 ); + filter->SetInput1( image1 ); + filter->SetInput2( image2 ); filter->Update( ); // Connect output diff --git a/plugins/ImageBooleanFilters/AndImageFilter.h b/plugins/ImageBooleanFilters/AndImageFilter.h index d8fdc61..037038b 100644 --- a/plugins/ImageBooleanFilters/AndImageFilter.h +++ b/plugins/ImageBooleanFilters/AndImageFilter.h @@ -1,7 +1,7 @@ #ifndef __cpPluginsImageBooleanFilters__AndImageFilter__h__ #define __cpPluginsImageBooleanFilters__AndImageFilter__h__ -#include +#include #include namespace cpPluginsImageBooleanFilters @@ -19,7 +19,7 @@ namespace cpPluginsImageBooleanFilters protected: template< class _TImage > - inline void _GD0( _TImage* image0 ); + inline void _GD0( _TImage* image1 ); }; } // ecapseman diff --git a/plugins/ImageBooleanFilters/ImageBooleanFilters.i b/plugins/ImageBooleanFilters/ImageBooleanFilters.i new file mode 100644 index 0000000..4fc6e7a --- /dev/null +++ b/plugins/ImageBooleanFilters/ImageBooleanFilters.i @@ -0,0 +1,12 @@ +header #define ITK_MANUAL_INSTANTIATION + +define filters=And;Or;Xor +define functors=AND;OR;XOR +define all_ints=#int_types#;unsigned #int_types# + +tinclude itkBinaryFunctorImageFilter:h|hxx +cinclude itk#filters#ImageFilter.h + +instances itk::BinaryFunctorImageFilter< itk::Image< #all_ints#, #process_dims# >, itk::Image< #all_ints#, #process_dims# >, itk::Image< #all_ints#, #process_dims# >, itk::Functor::#functors#< #all_ints#, #all_ints#, #all_ints# > > + +** eof - $RCSfile$ diff --git a/plugins/ImageBooleanFilters/OrImageFilter.cxx b/plugins/ImageBooleanFilters/OrImageFilter.cxx index af04700..3c7712a 100644 --- a/plugins/ImageBooleanFilters/OrImageFilter.cxx +++ b/plugins/ImageBooleanFilters/OrImageFilter.cxx @@ -1,17 +1,19 @@ -#include +#include #include +#include #include -#include // ------------------------------------------------------------------------- cpPluginsImageBooleanFilters::OrImageFilter:: OrImageFilter( ) : Superclass( ) { - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false ); - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", true, false ); - this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); + typedef cpPlugins::DataObjects::Image _TImage; + + this->_ConfigureInput< _TImage >( "Input1", true, false ); + this->_ConfigureInput< _TImage >( "Input2", true, false ); + this->_ConfigureOutput< _TImage >( "Output" ); } // ------------------------------------------------------------------------- @@ -24,26 +26,26 @@ cpPluginsImageBooleanFilters::OrImageFilter:: void cpPluginsImageBooleanFilters::OrImageFilter:: _GenerateData( ) { - auto o = this->GetInputData( "Input0" ); - cpPlugins_Demangle_ImageIntegers_Dims( o, _GD0 ); - else this->_Error( "Invalid input image." ); + auto o = this->GetInputData( "Input1" ); + cpPlugins_Demangle_Image_IntPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > void cpPluginsImageBooleanFilters::OrImageFilter:: -_GD0( _TImage* image0 ) +_GD0( _TImage* image1 ) { typedef itk::OrImageFilter< _TImage, _TImage > _TFilter; - auto image1 = this->GetInputData< _TImage >( "Input1" ); - if( image1 == NULL ) + auto image2 = this->GetInputData< _TImage >( "Input2" ); + if( image2 == NULL ) this->_Error( "Incompatible second input image." ); // Configure filter auto filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( 0, image0 ); - filter->SetInput( 1, image1 ); + filter->SetInput1( image1 ); + filter->SetInput2( image2 ); filter->Update( ); // Connect output diff --git a/plugins/ImageBooleanFilters/OrImageFilter.h b/plugins/ImageBooleanFilters/OrImageFilter.h index 426ccbe..c7522b9 100644 --- a/plugins/ImageBooleanFilters/OrImageFilter.h +++ b/plugins/ImageBooleanFilters/OrImageFilter.h @@ -1,7 +1,7 @@ #ifndef __cpPluginsImageBooleanFilters__OrImageFilter__h__ #define __cpPluginsImageBooleanFilters__OrImageFilter__h__ -#include +#include #include namespace cpPluginsImageBooleanFilters @@ -19,7 +19,7 @@ namespace cpPluginsImageBooleanFilters protected: template< class _TImage > - inline void _GD0( _TImage* image0 ); + inline void _GD0( _TImage* image1 ); }; } // ecapseman diff --git a/plugins/ImageBooleanFilters/XorImageFilter.cxx b/plugins/ImageBooleanFilters/XorImageFilter.cxx index fdb0a5d..30dd6f5 100644 --- a/plugins/ImageBooleanFilters/XorImageFilter.cxx +++ b/plugins/ImageBooleanFilters/XorImageFilter.cxx @@ -1,17 +1,19 @@ -#include +#include #include +#include #include -#include // ------------------------------------------------------------------------- cpPluginsImageBooleanFilters::XorImageFilter:: XorImageFilter( ) : Superclass( ) { - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false ); - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", true, false ); - this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); + typedef cpPlugins::DataObjects::Image _TImage; + + this->_ConfigureInput< _TImage >( "Input1", true, false ); + this->_ConfigureInput< _TImage >( "Input2", true, false ); + this->_ConfigureOutput< _TImage >( "Output" ); } // ------------------------------------------------------------------------- @@ -24,26 +26,26 @@ cpPluginsImageBooleanFilters::XorImageFilter:: void cpPluginsImageBooleanFilters::XorImageFilter:: _GenerateData( ) { - auto o = this->GetInputData( "Input0" ); - cpPlugins_Demangle_ImageIntegers_Dims( o, _GD0 ); - else this->_Error( "Invalid input image." ); + auto o = this->GetInputData( "Input1" ); + cpPlugins_Demangle_Image_IntPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > void cpPluginsImageBooleanFilters::XorImageFilter:: -_GD0( _TImage* image0 ) +_GD0( _TImage* image1 ) { typedef itk::XorImageFilter< _TImage, _TImage > _TFilter; - auto image1 = this->GetInputData< _TImage >( "Input1" ); - if( image1 == NULL ) + auto image2 = this->GetInputData< _TImage >( "Input2" ); + if( image2 == NULL ) this->_Error( "Incompatible second input image." ); // Configure filter auto filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( 0, image0 ); - filter->SetInput( 1, image1 ); + filter->SetInput1( image1 ); + filter->SetInput2( image2 ); filter->Update( ); // Connect output diff --git a/plugins/ImageBooleanFilters/XorImageFilter.h b/plugins/ImageBooleanFilters/XorImageFilter.h index ab121f5..3005c18 100644 --- a/plugins/ImageBooleanFilters/XorImageFilter.h +++ b/plugins/ImageBooleanFilters/XorImageFilter.h @@ -1,7 +1,7 @@ #ifndef __cpPluginsImageBooleanFilters__XorImageFilter__h__ #define __cpPluginsImageBooleanFilters__XorImageFilter__h__ -#include +#include #include namespace cpPluginsImageBooleanFilters @@ -19,7 +19,7 @@ namespace cpPluginsImageBooleanFilters protected: template< class _TImage > - inline void _GD0( _TImage* image0 ); + inline void _GD0( _TImage* image1 ); }; } // ecapseman diff --git a/plugins/ImageDistanceMaps/BinaryContourImageFilter.cxx b/plugins/ImageDistanceMaps/BinaryContourImageFilter.cxx index c6d0e16..ade2580 100644 --- a/plugins/ImageDistanceMaps/BinaryContourImageFilter.cxx +++ b/plugins/ImageDistanceMaps/BinaryContourImageFilter.cxx @@ -34,7 +34,7 @@ void cpPluginsImageDistanceMaps::BinaryContourImageFilter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); - cpPlugins_Demangle_Image_VisualDims( o, _GD0, ) + cpPlugins_Demangle_Image_VisualDims_1( o, _GD0 ) this->_Error( "Invalid input image dimension." ); } @@ -43,7 +43,7 @@ template< class _TImage > void cpPluginsImageDistanceMaps::BinaryContourImageFilter:: _GD0( _TImage* image ) { - cpPlugins_Demangle_Image_ScalarPixels( image, _GD1, _TImage::ImageDimension, ) + cpPlugins_Demangle_Image_ScalarPixels_1( image, _GD1, _TImage::ImageDimension ) this->_Error( "Invalid input image pixel type." ); } diff --git a/plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.cxx b/plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.cxx index d34d1df..89b52f7 100644 --- a/plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.cxx +++ b/plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.cxx @@ -45,7 +45,7 @@ void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); - cpPlugins_Demangle_Image_VisualDims( o, _GD0, ) + cpPlugins_Demangle_Image_VisualDims_1( o, _GD0 ) this->_Error( "Invalid input image dimension." ); } @@ -54,7 +54,7 @@ template< class _TImage > void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter:: _GD0( _TImage* image ) { - cpPlugins_Demangle_Image_ScalarPixels( image, _GD1, _TImage::ImageDimension, ) + cpPlugins_Demangle_Image_ScalarPixels_1( image, _GD1, _TImage::ImageDimension ) this->_Error( "Invalid input image pixel type." ); } diff --git a/plugins/ImageGenericFilters/ImageGenericFilters.i b/plugins/ImageGenericFilters/ImageGenericFilters.i new file mode 100644 index 0000000..5ddb452 --- /dev/null +++ b/plugins/ImageGenericFilters/ImageGenericFilters.i @@ -0,0 +1,18 @@ +header #define ITK_MANUAL_INSTANTIATION + +tinclude itkRegionOfInterestImageFilter:h|hxx +tinclude itkRescaleIntensityImageFilter:h|hxx +tinclude itkMinimumMaximumImageCalculator:h|hxx + +cinclude itk#color_pixels#.h +cinclude itkImageAlgorithm.hxx +cinclude itkUnaryFunctorImageFilter.hxx + +instances itk::RegionOfInterestImageFilter< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #scalar_pixels#, #process_dims# > > +instances itk::RegionOfInterestImageFilter< itk::Image< itk::#color_pixels#< #scalar_pixels# >, #process_dims# >, itk::Image< itk::#color_pixels#< #scalar_pixels# >, #process_dims# > > + +instances itk::RescaleIntensityImageFilter< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #scalar_pixels#, #process_dims# > > + +instances itk::MinimumMaximumImageCalculator< itk::Image< #scalar_pixels#, #process_dims# > > + +** eof - $RCSfile$ diff --git a/plugins/ImageGenericFilters/MinimumMaximumCalculator.cxx b/plugins/ImageGenericFilters/MinimumMaximumCalculator.cxx index 822f61f..df327b8 100644 --- a/plugins/ImageGenericFilters/MinimumMaximumCalculator.cxx +++ b/plugins/ImageGenericFilters/MinimumMaximumCalculator.cxx @@ -1,17 +1,23 @@ #include #include #include +#include +#include #include +#include // ------------------------------------------------------------------------- cpPluginsImageGenericFilters::MinimumMaximumCalculator:: MinimumMaximumCalculator( ) : Superclass( ) { - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input", true, false ); - this->_ConfigureOutput< cpPlugins::DataObjects::Mesh >( "Maximum" ); - this->_ConfigureOutput< cpPlugins::DataObjects::Mesh >( "Minimum" ); + typedef cpPlugins::DataObjects::Image _TImage; + typedef cpPlugins::DataObjects::Mesh _TMesh; + + this->_ConfigureInput< _TImage >( "Input", true, false ); + this->_ConfigureOutput< _TMesh >( "Maximum" ); + this->_ConfigureOutput< _TMesh >( "Minimum" ); } // ------------------------------------------------------------------------- @@ -25,8 +31,8 @@ void cpPluginsImageGenericFilters::MinimumMaximumCalculator:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); - cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 ); - else this->_Error( "Invalid input image." ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- diff --git a/plugins/ImageGenericFilters/MinimumMaximumCalculator.h b/plugins/ImageGenericFilters/MinimumMaximumCalculator.h index 695cb84..0459a3b 100644 --- a/plugins/ImageGenericFilters/MinimumMaximumCalculator.h +++ b/plugins/ImageGenericFilters/MinimumMaximumCalculator.h @@ -19,7 +19,7 @@ namespace cpPluginsImageGenericFilters protected: template< class _TImage > - inline void _GD0( _TImage* input ); + inline void _GD0( _TImage* input ); }; } // ecapseman diff --git a/plugins/ImageGenericFilters/RegionOfInterestImageFilter.cxx b/plugins/ImageGenericFilters/RegionOfInterestImageFilter.cxx index b6bc546..e73ac59 100644 --- a/plugins/ImageGenericFilters/RegionOfInterestImageFilter.cxx +++ b/plugins/ImageGenericFilters/RegionOfInterestImageFilter.cxx @@ -1,7 +1,10 @@ #include #include #include +#include +#include +#include #include // ------------------------------------------------------------------------- @@ -9,9 +12,11 @@ cpPluginsImageGenericFilters::RegionOfInterestImageFilter:: RegionOfInterestImageFilter( ) : Superclass( ) { - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input", true, false ); - this->_ConfigureInput< cpPlugins::DataObjects::BoundingBox >( "BoundingBox", true, false ); - this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); + typedef cpPlugins::DataObjects::Image _TImage; + typedef cpPlugins::DataObjects::BoundingBox _TBBox; + this->_ConfigureInput< _TImage >( "Input", true, false ); + this->_ConfigureInput< _TBBox >( "BoundingBox", true, false ); + this->_ConfigureOutput< _TImage >( "Output" ); } // ------------------------------------------------------------------------- @@ -25,8 +30,9 @@ void cpPluginsImageGenericFilters::RegionOfInterestImageFilter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); - cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 ); - else this->_Error( "Invalid input image." ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + cpPlugins_Demangle_Image_ColorPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- @@ -34,13 +40,14 @@ template< class _TImage > void cpPluginsImageGenericFilters::RegionOfInterestImageFilter:: _GD0( _TImage* input ) { + typedef cpPlugins::DataObjects::BoundingBox _TBBox; typedef itk::RegionOfInterestImageFilter< _TImage, _TImage > _TFilter; typedef typename _TImage::IndexType _TIndex; typedef typename _TImage::PointType _TPoint; typedef typename _TImage::RegionType _TRegion; typedef typename _TImage::SizeType _TSize; - auto bb = this->GetInput< cpPlugins::DataObjects::BoundingBox >( "BoundingBox" ); + auto bb = this->GetInput< _TBBox >( "BoundingBox" ); _TIndex i0, i1; input->TransformPhysicalPointToIndex( bb->GetMinimum< _TPoint >( ), i0 ); diff --git a/plugins/ImageGenericFilters/RegionOfInterestImageFilter.h b/plugins/ImageGenericFilters/RegionOfInterestImageFilter.h index 1f2f2c5..04be0a5 100644 --- a/plugins/ImageGenericFilters/RegionOfInterestImageFilter.h +++ b/plugins/ImageGenericFilters/RegionOfInterestImageFilter.h @@ -19,7 +19,7 @@ namespace cpPluginsImageGenericFilters protected: template< class _TImage > - inline void _GD0( _TImage* input ); + inline void _GD0( _TImage* input ); }; } // ecapseman diff --git a/plugins/ImageGenericFilters/RescaleIntensityImageFilter.cxx b/plugins/ImageGenericFilters/RescaleIntensityImageFilter.cxx index 52a3635..38681d9 100644 --- a/plugins/ImageGenericFilters/RescaleIntensityImageFilter.cxx +++ b/plugins/ImageGenericFilters/RescaleIntensityImageFilter.cxx @@ -1,5 +1,6 @@ #include #include +#include #include @@ -8,8 +9,9 @@ cpPluginsImageGenericFilters::RescaleIntensityImageFilter:: RescaleIntensityImageFilter( ) : Superclass( ) { - this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input", true, false ); - this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" ); + typedef cpPlugins::DataObjects::Image _TImage; + this->_ConfigureInput< _TImage >( "Input", true, false ); + this->_ConfigureOutput< _TImage >( "Output" ); this->m_Parameters.ConfigureAsReal( "OutputMinimum" ); this->m_Parameters.ConfigureAsReal( "OutputMaximum" ); @@ -29,8 +31,8 @@ void cpPluginsImageGenericFilters::RescaleIntensityImageFilter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); - cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 ); - else this->_Error( "Invalid input image." ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- diff --git a/plugins/ImageGradientFilters/GulsunTekImageFilter.cxx b/plugins/ImageGradientFilters/GulsunTekImageFilter.cxx index b707d00..52525d9 100644 --- a/plugins/ImageGradientFilters/GulsunTekImageFilter.cxx +++ b/plugins/ImageGradientFilters/GulsunTekImageFilter.cxx @@ -1,13 +1,16 @@ -#include +#include #include +#include + +/* TODO + #include + #include -#include -#include - -#include -#include -#include -#include + #include + #include + #include + #include +*/ // ------------------------------------------------------------------------- cpPluginsImageGradientFilters::GulsunTekImageFilter:: diff --git a/plugins/ImageGradientFilters/GulsunTekImageFilter.h b/plugins/ImageGradientFilters/GulsunTekImageFilter.h index aafa51f..e48623c 100644 --- a/plugins/ImageGradientFilters/GulsunTekImageFilter.h +++ b/plugins/ImageGradientFilters/GulsunTekImageFilter.h @@ -1,7 +1,7 @@ #ifndef __cpPluginsImageGradientFilters__GulsunTekImageFilter__h__ #define __cpPluginsImageGradientFilters__GulsunTekImageFilter__h__ -#include +#include #include namespace cpPluginsImageGradientFilters diff --git a/plugins/ImageGradientFilters/MultiScaleGaussianImageFilter.cxx b/plugins/ImageGradientFilters/MultiScaleGaussianImageFilter.cxx index a95cacb..d4e74e8 100644 --- a/plugins/ImageGradientFilters/MultiScaleGaussianImageFilter.cxx +++ b/plugins/ImageGradientFilters/MultiScaleGaussianImageFilter.cxx @@ -1,18 +1,22 @@ -#include +#include #include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include + +/* TODO + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +*/ // ------------------------------------------------------------------------- cpPluginsImageGradientFilters::MultiScaleGaussianImageFilter:: @@ -42,8 +46,8 @@ void cpPluginsImageGradientFilters::MultiScaleGaussianImageFilter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); - cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 ); - else this->_Error( "Invalid input image." ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- diff --git a/plugins/ImageGradientFilters/MultiScaleGaussianImageFilter.h b/plugins/ImageGradientFilters/MultiScaleGaussianImageFilter.h index 9781cb3..29b0b6f 100644 --- a/plugins/ImageGradientFilters/MultiScaleGaussianImageFilter.h +++ b/plugins/ImageGradientFilters/MultiScaleGaussianImageFilter.h @@ -1,7 +1,7 @@ #ifndef __cpPluginsImageGradientFilters__MultiScaleGaussianImageFilter__h__ #define __cpPluginsImageGradientFilters__MultiScaleGaussianImageFilter__h__ -#include +#include #include namespace cpPluginsImageGradientFilters @@ -19,10 +19,10 @@ namespace cpPluginsImageGradientFilters protected: template< class _TImage > - inline void _GD0( _TImage* image ); + inline void _GD0( _TImage* image ); template< class _TInputImage, class _TScalar > - inline void _GD1( _TInputImage* o ); + inline void _GD1( _TInputImage* o ); }; } // ecapseman diff --git a/plugins/Widgets/LineWidget.cxx b/plugins/Widgets/LineWidget.cxx index f072a94..ab7e320 100644 --- a/plugins/Widgets/LineWidget.cxx +++ b/plugins/Widgets/LineWidget.cxx @@ -9,6 +9,7 @@ #include #include #include +#include #include // ------------------------------------------------------------------------- diff --git a/plugins/Widgets/SplineWidget.cxx b/plugins/Widgets/SplineWidget.cxx index bb68821..258c0bd 100644 --- a/plugins/Widgets/SplineWidget.cxx +++ b/plugins/Widgets/SplineWidget.cxx @@ -6,6 +6,7 @@ #include #include +#include #include #include #include -- 2.47.1