From: Leonardo Florez-Valencia Date: Mon, 31 Oct 2016 14:41:16 +0000 (-0500) Subject: ... X-Git-Tag: v0.1~70 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=0ddc14324268de8d6af08eaa89163a60ce1d16ce;p=cpPlugins.git ... --- diff --git a/lib/cpExtensions/Algorithms/CPRImageFilter.h b/lib/cpExtensions/Algorithms/CPRImageFilter.h new file mode 100644 index 0000000..9161260 --- /dev/null +++ b/lib/cpExtensions/Algorithms/CPRImageFilter.h @@ -0,0 +1,68 @@ +#ifndef __cpExtensions__Algorithms__CPRImageFilter__h__ +#define __cpExtensions__Algorithms__CPRImageFilter__h__ + +#include +#include + +namespace cpExtensions +{ + namespace Algorithms + { + /** + */ + template< class _TImage, class _TCurve > + class CPRImageFilter + : public itk::ImageToImageFilter< _TImage, _TImage > + { + public: + typedef CPRImageFilter Self; + typedef itk::ImageToImageFilter< _TImage, _TImage > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef _TImage TImage; + typedef _TCurve TCurve; + typedef typename TCurve::TScalar TScalar; + + typedef IsoImageSlicer< TImage, TScalar > TSlicer; + typedef typename TSlicer::TInterpolateFunction TInterpolateFunction; + + public: + itkNewMacro( Self ); + itkTypeMacro( CPRImageFilter, itk::ImageToImageFilter ); + + itkGetConstMacro( SliceRadius, double ); + itkGetObjectMacro( Interpolator, TInterpolateFunction ); + + itkSetMacro( SliceRadius, double ); + itkSetObjectMacro( Interpolator, TInterpolateFunction ); + + public: + _TCurve* GetCurve( ); + const _TCurve* GetCurve( ) const; + void SetCurve( _TCurve* curve ); + + protected: + CPRImageFilter( ); + virtual ~CPRImageFilter( ); + + virtual void GenerateOutputInformation( ) cpExtensions_OVERRIDE; + virtual void GenerateInputRequestedRegion( ) cpExtensions_OVERRIDE; + virtual void GenerateData( ) cpExtensions_OVERRIDE; + + protected: + double m_SliceRadius; + typename TInterpolateFunction::Pointer m_Interpolator; + }; + + } // ecapseman + +} // ecapseman + +#ifndef ITK_MANUAL_INSTANTIATION +# include +#endif // ITK_MANUAL_INSTANTIATION + +#endif // __cpExtensions__Algorithms__CPRImageFilter__h__ + +// eof - $RCSfile$ diff --git a/lib/cpExtensions/Algorithms/CPRImageFilter.hxx b/lib/cpExtensions/Algorithms/CPRImageFilter.hxx new file mode 100644 index 0000000..a29c656 --- /dev/null +++ b/lib/cpExtensions/Algorithms/CPRImageFilter.hxx @@ -0,0 +1,79 @@ +#ifndef __cpExtensions__Algorithms__CPRImageFilter__hxx__ +#define __cpExtensions__Algorithms__CPRImageFilter__hxx__ + +// ------------------------------------------------------------------------- +template< class _TImage, class _TCurve > +_TCurve* cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >:: +GetCurve( ) +{ + return( + dynamic_cast< _TCurve* >( this->itk::ProcessObject::GetInput( 1 ) ) + ); +} + +// ------------------------------------------------------------------------- +template< class _TImage, class _TCurve > +const _TCurve* cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >:: +GetCurve( ) const +{ + return( + dynamic_cast< const _TCurve* >( this->itk::ProcessObject::GetInput( 1 ) ) + ); +} + +// ------------------------------------------------------------------------- +template< class _TImage, class _TCurve > +void cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >:: +SetCurve( _TCurve* curve ) +{ + this->itk::ProcessObject::SetInput( 1, curve ); +} + +// ------------------------------------------------------------------------- +template< class _TImage, class _TCurve > +cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >:: +CPRImageFilter( ) + : Superclass( ), + m_SliceRadius( 0 ) +{ + this->Superclass::SetNumberOfRequiredInputs( 2 ); +} + +// ------------------------------------------------------------------------- +template< class _TImage, class _TCurve > +cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >:: +~CPRImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +template< class _TImage, class _TCurve > +void cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >:: +GenerateOutputInformation( ) +{ +} + +// ------------------------------------------------------------------------- +template< class _TImage, class _TCurve > +void cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >:: +GenerateInputRequestedRegion( ) +{ + TImage* input = const_cast< TImage* >( this->GetInput( ) ); + if( input != NULL ) + input->SetRequestedRegionToLargestPossibleRegion( ); +} + +// ------------------------------------------------------------------------- +template< class _TImage, class _TCurve > +void cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve >:: +GenerateData( ) +{ + /* TODO + double m_SliceRadius + typename TInterpolateFunction::Pointer m_Interpolator + */ +} + +#endif // __cpExtensions__Algorithms__CPRImageFilter__hxx__ + +// eof - $RCSfile$ diff --git a/lib/cpExtensions/Algorithms/IsoImageSlicer.h b/lib/cpExtensions/Algorithms/IsoImageSlicer.h index dad9c7a..9190430 100644 --- a/lib/cpExtensions/Algorithms/IsoImageSlicer.h +++ b/lib/cpExtensions/Algorithms/IsoImageSlicer.h @@ -177,7 +177,7 @@ namespace cpExtensions } // ecapseman #ifndef ITK_MANUAL_INSTANTIATION -#include +# include #endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__ISOIMAGESLICER__H__ diff --git a/plugins/AnisotropicDiffusion/AnisotropicDiffusion.i b/plugins/AnisotropicDiffusion/AnisotropicDiffusion.i new file mode 100644 index 0000000..95d1fce --- /dev/null +++ b/plugins/AnisotropicDiffusion/AnisotropicDiffusion.i @@ -0,0 +1,8 @@ + +tinclude itkAnisotropicDiffusionImageFilter:h|hxx +tinclude itkCurvatureNDAnisotropicDiffusionFunction:h|hxx + +instances itk::AnisotropicDiffusionImageFilter< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #real_types#, #process_dims# > > +instances itk::CurvatureNDAnisotropicDiffusionFunction< itk::Image< #real_types#, #process_dims# > > + +** eof - $RCSfile$ diff --git a/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.cxx b/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.cxx index d2f2aea..d8ce659 100644 --- a/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.cxx +++ b/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.cxx @@ -3,31 +3,28 @@ #include #include -/* TODO - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -*/ // ------------------------------------------------------------------------- cpPluginsAnisotropicDiffusion::CurvatureAnisotropicDiffusionImageFilter:: CurvatureAnisotropicDiffusionImageFilter( ) : 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.ConfigureAsUint( "NumberOfIterations" ); this->m_Parameters.ConfigureAsBool( "UseImageSpacing" ); this->m_Parameters.ConfigureAsReal( "ConductanceParameter" ); this->m_Parameters.ConfigureAsReal( "TimeStep" ); + std::vector< std::string > choices; +#ifdef cpPlugins_CONFIG_REAL_TYPES_float + choices.push_back( "float" ); +#endif // cpPlugins_CONFIG_REAL_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_double + choices.push_back( "double" ); +#endif // cpPlugins_CONFIG_REAL_TYPES_double + this->m_Parameters.ConfigureAsChoices( "OutputResolution", choices ); this->m_Parameters.SetUint( "NumberOfIterations", 5 ); this->m_Parameters.SetBool( "UseImageSpacing", false ); @@ -46,7 +43,7 @@ void cpPluginsAnisotropicDiffusion::CurvatureAnisotropicDiffusionImageFilter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); - cpPlugins_Demangle_Image_ScalarPixels_VisualDims_1( o, _GD0 ) + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) this->_Error( "No valid input image." ); } @@ -55,7 +52,25 @@ template< class _TImage > void cpPluginsAnisotropicDiffusion::CurvatureAnisotropicDiffusionImageFilter:: _GD0( _TImage* image ) { - typedef itk::CurvatureAnisotropicDiffusionImageFilter< _TImage, _TImage > _TFilter; + std::string out_res = + this->m_Parameters.GetSelectedChoice( "OutputResolution" ); +#ifdef cpPlugins_CONFIG_REAL_TYPES_float + if( out_res == "float" ) this->_GD1< _TImage, float >( image ); +#endif // cpPlugins_CONFIG_REAL_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_double + if( out_res == "double" ) this->_GD1< _TImage, double >( image ); +#endif // cpPlugins_CONFIG_REAL_TYPES_double +} + +// ------------------------------------------------------------------------- +template< class _TImage, class _TScalar > +void cpPluginsAnisotropicDiffusion::CurvatureAnisotropicDiffusionImageFilter:: +_GD1( _TImage* image ) +{ + typedef itk::Image< _TScalar, _TImage::ImageDimension > _TOutImage; + typedef + itk::CurvatureAnisotropicDiffusionImageFilter< _TImage, _TOutImage > + _TFilter; // Configure filter _TFilter* filter = this->_CreateITK< _TFilter >( ); diff --git a/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.h b/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.h index fb92cd1..1271688 100644 --- a/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.h +++ b/plugins/AnisotropicDiffusion/CurvatureAnisotropicDiffusionImageFilter.h @@ -20,6 +20,9 @@ namespace cpPluginsAnisotropicDiffusion protected: template< class _TImage > inline void _GD0( _TImage* image ); + + template< class _TImage, class _TScalar > + inline void _GD1( _TImage* image ); }; } // ecapseman diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index e112573..fccbeca 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -12,6 +12,7 @@ SET( ImageGenericFilters ImageGradientFilters ImageMeshFilters + ImageSliceFilters ImageSources ImageThresholdFilters IO diff --git a/plugins/ImageBooleanFilters/ImageBooleanFilters.i b/plugins/ImageBooleanFilters/ImageBooleanFilters.i index 4fc6e7a..c185fbd 100644 --- a/plugins/ImageBooleanFilters/ImageBooleanFilters.i +++ b/plugins/ImageBooleanFilters/ImageBooleanFilters.i @@ -1,12 +1,15 @@ header #define ITK_MANUAL_INSTANTIATION -define filters=And;Or;Xor +define filters=And;Or;Xor;Not define functors=AND;OR;XOR define all_ints=#int_types#;unsigned #int_types# tinclude itkBinaryFunctorImageFilter:h|hxx +tinclude itkUnaryFunctorImageFilter: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# > > +instances itk::UnaryFunctorImageFilter< itk::Image< #all_ints#, #process_dims# >, itk::Image< #all_ints#, #process_dims# >, itk::Functor::NOT< #all_ints#, #all_ints# > > + ** eof - $RCSfile$ diff --git a/plugins/ImageBooleanFilters/NotImageFilter.cxx b/plugins/ImageBooleanFilters/NotImageFilter.cxx new file mode 100644 index 0000000..149dc24 --- /dev/null +++ b/plugins/ImageBooleanFilters/NotImageFilter.cxx @@ -0,0 +1,49 @@ +#include +#include +#include + +#include + +// ------------------------------------------------------------------------- +cpPluginsImageBooleanFilters::NotImageFilter:: +NotImageFilter( ) + : Superclass( ) +{ + typedef cpPlugins::DataObjects::Image _TImage; + + this->_ConfigureInput< _TImage >( "Input", true, false ); + this->_ConfigureOutput< _TImage >( "Output" ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageBooleanFilters::NotImageFilter:: +~NotImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsImageBooleanFilters::NotImageFilter:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Input" ); + cpPlugins_Demangle_Image_IntPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpPluginsImageBooleanFilters::NotImageFilter:: +_GD0( _TImage* image ) +{ + typedef itk::NotImageFilter< _TImage, _TImage > _TFilter; + + // Configure filter + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( image ); + filter->Update( ); + + // Connect output + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/ImageBooleanFilters/NotImageFilter.h b/plugins/ImageBooleanFilters/NotImageFilter.h new file mode 100644 index 0000000..020d380 --- /dev/null +++ b/plugins/ImageBooleanFilters/NotImageFilter.h @@ -0,0 +1,29 @@ +#ifndef __cpPluginsImageBooleanFilters__NotImageFilter__h__ +#define __cpPluginsImageBooleanFilters__NotImageFilter__h__ + +#include +#include + +namespace cpPluginsImageBooleanFilters +{ + /** + */ + class cpPluginsImageBooleanFilters_EXPORT NotImageFilter + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + NotImageFilter, + cpPlugins::BaseObjects::ProcessObject, + ImageBooleanFilters + ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* image1 ); + }; + +} // ecapseman + +#endif // __cpPluginsImageBooleanFilters__NotImageFilter__h__ + +// eof - $RCSfile$ diff --git a/plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.cxx b/plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.cxx index 89b52f7..5a7a033 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_1( o, _GD0 ) + cpPlugins_Demangle_Image_ScalarPixels_VisualDims_1( o, _GD0 ) this->_Error( "Invalid input image dimension." ); } @@ -53,30 +53,21 @@ _GenerateData( ) template< class _TImage > void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter:: _GD0( _TImage* image ) -{ - cpPlugins_Demangle_Image_ScalarPixels_1( image, _GD1, _TImage::ImageDimension ) - this->_Error( "Invalid input image pixel type." ); -} - -// ------------------------------------------------------------------------- -template< class _TImage > -void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter:: -_GD1( _TImage* image ) { std::string out_res = this->m_Parameters.GetSelectedChoice( "OutputResolution" ); #ifdef cpPlugins_CONFIG_REAL_TYPES_float - if( out_res == "float" ) this->_GD2< _TImage, float >( image ); + if( out_res == "float" ) this->_GD1< _TImage, float >( image ); #endif // cpPlugins_CONFIG_REAL_TYPES_float #ifdef cpPlugins_CONFIG_REAL_TYPES_double - if( out_res == "double" ) this->_GD2< _TImage, double >( image ); + if( out_res == "double" ) this->_GD1< _TImage, double >( image ); #endif // cpPlugins_CONFIG_REAL_TYPES_double } // ------------------------------------------------------------------------- template< class _TImage, class _TScalar > void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter:: -_GD2( _TImage* image ) +_GD1( _TImage* image ) { typedef itk::Image< _TScalar, _TImage::ImageDimension > _TDMap; typedef diff --git a/plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.h b/plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.h index dabbacc..452e6c6 100644 --- a/plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.h +++ b/plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.h @@ -21,11 +21,8 @@ namespace cpPluginsImageDistanceMaps template< class _TImage > inline void _GD0( _TImage* image ); - template< class _TImage > - inline void _GD1( _TImage* image ); - template< class _TImage, class _TScalar > - inline void _GD2( _TImage* image ); + inline void _GD1( _TImage* image ); }; } // ecapseman diff --git a/plugins/ImageSliceFilters/ImageSliceFilters.i b/plugins/ImageSliceFilters/ImageSliceFilters.i new file mode 100644 index 0000000..cd8395a --- /dev/null +++ b/plugins/ImageSliceFilters/ImageSliceFilters.i @@ -0,0 +1 @@ +** eof - $RCSfile$