From: Leonardo Flórez-Valencia Date: Tue, 8 Nov 2016 16:07:36 +0000 (-0500) Subject: ... X-Git-Tag: v0.1~56 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=d8ebffc6ece697ddf7b358946ef5d9c9cd7191fe;p=cpPlugins.git ... --- diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index fbe5996..1a97df6 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -52,6 +52,10 @@ TARGET_LINK_LIBRARIES( cpPluginsImageSliceFilters cpPluginsImageGenericFilters ) +TARGET_LINK_LIBRARIES( + cpPluginsImageGradientFilters + cpPluginsImageGenericFilters + ) IF(ParabolicMorphology_LOADED) TARGET_LINK_LIBRARIES( cpPluginsImageParaMorphologyFilters diff --git a/plugins/ImageGenericFilters/GaussianBlurImageFilter.cxx b/plugins/ImageGenericFilters/GaussianBlurImageFilter.cxx deleted file mode 100644 index 10415cd..0000000 --- a/plugins/ImageGenericFilters/GaussianBlurImageFilter.cxx +++ /dev/null @@ -1,77 +0,0 @@ -#include -#include -#include - -#include -#include - -// ------------------------------------------------------------------------- -cpPluginsImageGenericFilters::GaussianBlurImageFilter:: -GaussianBlurImageFilter( ) - : Superclass( ) -{ - typedef cpPlugins::DataObjects::Image _TImage; - this->_ConfigureInput< _TImage >( "Input", true, false ); - this->_ConfigureOutput< _TImage >( "Output" ); - - this->m_Parameters.ConfigureAsReal( "MaximumError", 1e-3 ); - this->m_Parameters.ConfigureAsReal( "Sigma", 1 ); - this->m_Parameters.ConfigureAsUint( "MaximumKernelWidth", 32 ); - this->m_Parameters.ConfigureAsRealTypesChoices( "OutputResolution" ); -} - -// ------------------------------------------------------------------------- -cpPluginsImageGenericFilters::GaussianBlurImageFilter:: -~GaussianBlurImageFilter( ) -{ -} - -// ------------------------------------------------------------------------- -void cpPluginsImageGenericFilters::GaussianBlurImageFilter:: -_GenerateData( ) -{ - auto o = this->GetInputData( "Input" ); - cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) - this->_Error( "Invalid input image." ); -} - -// ------------------------------------------------------------------------- -template< class _TInput > -void cpPluginsImageGenericFilters::GaussianBlurImageFilter:: -_GD0( _TInput* input ) -{ - std::string t = this->m_Parameters.GetSelectedChoice( "OutputResolution" ); -#ifdef cpPlugins_CONFIG_REAL_TYPES_float - if( t == "float" ) this->_GD1< _TInput, float >( input ); -#endif // cpPlugins_CONFIG_REAL_TYPES_float -#ifdef cpPlugins_CONFIG_REAL_TYPES_double - if( t == "double" ) this->_GD1< _TInput, double >( input ); -#endif // cpPlugins_CONFIG_REAL_TYPES_double -} - -// ------------------------------------------------------------------------- -template< class _TInput, class _TOutputPixel > -void cpPluginsImageGenericFilters::GaussianBlurImageFilter:: -_GD1( _TInput* input ) -{ - /* TODO - typedef itk::GaussianBlurImageFunction< _TInput, _TOutputPixel > _TFunction; - typedef itk::Image< _TOutputPixel, _TInput::ImageDimension > _TOutput; - typedef itk::UnaryFunctorImageFilter< _TInput, _TOutput, _TFunction > _TFilter; - - auto filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( input ); - - typename _TFunction::ErrorArrayType e; - e.Fill( this->m_Parameters.GetReal( "MaximumError" ) ); - filter->GetFunctor( ).SetMaximumError( e ); - filter->GetFunctor( ).SetSigma( this->m_Parameters.GetReal( "Sigma" ) ); - filter->GetFunctor( ).SetMaximumKernelWidth( - this->m_Parameters.GetUint( "MaximumKernelWidth" ) - ); - filter->Update( ); - this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); - */ -} - -// eof - $RCSfile$ diff --git a/plugins/ImageGenericFilters/GaussianBlurImageFilter.h b/plugins/ImageGenericFilters/GaussianBlurImageFilter.h deleted file mode 100644 index 9faef0a..0000000 --- a/plugins/ImageGenericFilters/GaussianBlurImageFilter.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __cpPluginsImageGenericFilters__GaussianBlurImageFilter__h__ -#define __cpPluginsImageGenericFilters__GaussianBlurImageFilter__h__ - -#include -#include - -namespace cpPluginsImageGenericFilters -{ - /** - */ - class cpPluginsImageGenericFilters_EXPORT GaussianBlurImageFilter - : public cpPlugins::BaseObjects::ProcessObject - { - cpPluginsObject( - GaussianBlurImageFilter, - cpPlugins::BaseObjects::ProcessObject, - ImageFilters - ); - - protected: - template< class _TInput > - inline void _GD0( _TInput* input ); - - template< class _TInput, class _TOutputPixel > - inline void _GD1( _TInput* input ); - }; - -} // ecapseman - -#endif // __cpPluginsImageGenericFilters__GaussianBlurImageFilter__h__ - -// eof - $RCSfile$ diff --git a/plugins/ImageGenericFilters/ImageGenericFilters.i b/plugins/ImageGenericFilters/ImageGenericFilters.i index 1deff6b..d76a6f9 100644 --- a/plugins/ImageGenericFilters/ImageGenericFilters.i +++ b/plugins/ImageGenericFilters/ImageGenericFilters.i @@ -1,12 +1,14 @@ header #define ITK_MANUAL_INSTANTIATION define functions=NeighborhoodOperatorImageFunction;GaussianBlurImageFunction +define in_scalars=#scalar_pixels# +define out_scalars=#scalar_pixels# tinclude itkRegionOfInterestImageFilter:h|hxx tinclude itkRescaleIntensityImageFilter:h|hxx tinclude itkMinimumMaximumImageCalculator:h|hxx tinclude itkExtractImageFilter:h|hxx -* tinclude itk#functions#:h|hxx +tinclude itkCastImageFilter:h|hxx cinclude itk#color_pixels#.h cinclude itkImageAlgorithm.hxx @@ -20,6 +22,6 @@ instances itk::RescaleIntensityImageFilter< itk::Image< #scalar_pixels#, #proces instances itk::MinimumMaximumImageCalculator< itk::Image< #scalar_pixels#, #process_dims# > > -* instances itk::#functions#< itk::Image< #scalar_pixels#, #process_dims# >, #real_types# > +instances itk::CastImageFilter< itk::Image< #in_scalars#, #process_dims# >, itk::Image< #out_scalars#, #process_dims# > > ** eof - $RCSfile$ diff --git a/plugins/ImageGradientFilters/ImageGradientFilters.i b/plugins/ImageGradientFilters/ImageGradientFilters.i index 95bff3a..903e209 100644 --- a/plugins/ImageGradientFilters/ImageGradientFilters.i +++ b/plugins/ImageGradientFilters/ImageGradientFilters.i @@ -5,6 +5,7 @@ define all_funcs=GradientImageFunctionBase;#funcs# define itk_filters=RecursiveGaussianImageFilter;GradientRecursiveGaussianImageFilter tinclude itk#itk_filters#:h|hxx +tinclude itkSmoothingRecursiveGaussianImageFilter:h|hxx tinclude cpExtensions/Algorithms/#all_funcs#:h|hxx tinclude cpExtensions/Algorithms/ImageFunctionFilter:h|hxx tinclude cpExtensions/Algorithms/MultiScaleGaussianImageFilter:h|hxx @@ -27,4 +28,6 @@ instances cpExtensions::Algorithms::ImageFunctionFilter< itk::Image< itk::Covari instances cpExtensions::Algorithms::MultiScaleGaussianImageFilter< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< itk::CovariantVector< #real_types#, #process_dims# >, #process_dims# > > +instances itk::SmoothingRecursiveGaussianImageFilter< itk::Image< #scalar_pixels#, #process_dims# >, itk::Image< #real_types#, #process_dims# > > + ** eof - $RCSfile$ diff --git a/plugins/ImageGradientFilters/SmoothingRecursiveGaussianImageFilter.cxx b/plugins/ImageGradientFilters/SmoothingRecursiveGaussianImageFilter.cxx new file mode 100644 index 0000000..28944bc --- /dev/null +++ b/plugins/ImageGradientFilters/SmoothingRecursiveGaussianImageFilter.cxx @@ -0,0 +1,81 @@ +#include +#include +#include + +#include + +// ------------------------------------------------------------------------- +cpPluginsImageGradientFilters::SmoothingRecursiveGaussianImageFilter:: +SmoothingRecursiveGaussianImageFilter( ) + : Superclass( ) +{ + typedef cpPlugins::DataObjects::Image _TImage; + + this->_ConfigureInput< _TImage >( "Input", true, false ); + this->_ConfigureOutput< _TImage >( "Output" ); + + this->m_Parameters.ConfigureAsRealList( "SigmaArray" ); + this->m_Parameters.ConfigureAsRealTypesChoices( "OutputResolution" ); +} + +// ------------------------------------------------------------------------- +cpPluginsImageGradientFilters::SmoothingRecursiveGaussianImageFilter:: +~SmoothingRecursiveGaussianImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsImageGradientFilters::SmoothingRecursiveGaussianImageFilter:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Input" ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpPluginsImageGradientFilters::SmoothingRecursiveGaussianImageFilter:: +_GD0( _TImage* image ) +{ + auto choice = this->m_Parameters.GetSelectedChoice( "OutputResolution" ); +#ifdef cpPlugins_CONFIG_REAL_TYPES_float + if( choice == "float" ) this->_GD1< _TImage, float >( image ); +#endif // cpPlugins_CONFIG_REAL_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_double + if( choice == "double" ) this->_GD1< _TImage, double >( image ); +#endif // cpPlugins_CONFIG_REAL_TYPES_double +} + +// ------------------------------------------------------------------------- +template< class _TInput, class _TOutputPixel > +void cpPluginsImageGradientFilters::SmoothingRecursiveGaussianImageFilter:: +_GD1( _TInput* image ) +{ + typedef itk::Image< _TOutputPixel, _TInput::ImageDimension > _TOutput; + typedef + itk::SmoothingRecursiveGaussianImageFilter< _TInput, _TOutput > + _TFilter; + typedef typename _TFilter::SigmaArrayType _TSigmas; + + auto param_sigmas = this->m_Parameters.GetRealList( "SigmaArray" ); + unsigned int dim = + ( param_sigmas.size( ) < _TInput::ImageDimension )? + param_sigmas.size( ): + _TInput::ImageDimension; + _TSigmas sigmas; + sigmas.Fill( param_sigmas[ dim - 1 ] ); + for( unsigned d = 0; d < dim; ++d ) + sigmas[ d ] = param_sigmas[ d ]; + + // Configure filter + _TFilter* filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( image ); + filter->SetSigmaArray( sigmas ); + filter->Update( ); + + // Connect output + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/ImageGradientFilters/SmoothingRecursiveGaussianImageFilter.h b/plugins/ImageGradientFilters/SmoothingRecursiveGaussianImageFilter.h new file mode 100644 index 0000000..526b80c --- /dev/null +++ b/plugins/ImageGradientFilters/SmoothingRecursiveGaussianImageFilter.h @@ -0,0 +1,32 @@ +#ifndef __cpPluginsImageGradientFilters__SmoothingRecursiveGaussianImageFilter__h__ +#define __cpPluginsImageGradientFilters__SmoothingRecursiveGaussianImageFilter__h__ + +#include +#include + +namespace cpPluginsImageGradientFilters +{ + /** + */ + class cpPluginsImageGradientFilters_EXPORT SmoothingRecursiveGaussianImageFilter + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + SmoothingRecursiveGaussianImageFilter, + cpPlugins::BaseObjects::ProcessObject, + ImageGradientFilters + ); + + protected: + template< class _TInput > + inline void _GD0( _TInput* image ); + + template< class _TInput, class _TOutputPixel > + inline void _GD1( _TInput* image ); + }; + +} // ecapseman + +#endif // __cpPluginsImageGradientFilters__SmoothingRecursiveGaussianImageFilter__h__ + +// eof - $RCSfile$