X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=plugins%2FImageDistanceMaps%2FSignedMaurerDistanceMapImageFilter.cxx;h=ad2b183eba272b891532fff850df4ccf94eeda30;hb=db0a767418f78b371c1e4fb0db00e6b75df74ff3;hp=41001947368179dc1a9d1027488c5cd4a068f2ce;hpb=f6e163be0bf2ffeb19239bb31c1df936017cdc8e;p=cpPlugins.git diff --git a/plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.cxx b/plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.cxx index 4100194..ad2b183 100644 --- a/plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.cxx +++ b/plugins/ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.cxx @@ -1,20 +1,18 @@ -#include +#include #include +#include -#include #include -#include -#include -#include -#include // ------------------------------------------------------------------------- cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter:: SignedMaurerDistanceMapImageFilter( ) : 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( "BackgroundValue" ); this->m_Parameters.ConfigureAsBool( "InsideIsPositive" ); @@ -22,15 +20,18 @@ SignedMaurerDistanceMapImageFilter( ) this->m_Parameters.ConfigureAsBool( "UseImageSpacing" ); 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.SetReal( "BackgroundValue", 0 ); this->m_Parameters.SetBool( "InsideIsPositive", true ); this->m_Parameters.SetBool( "SquaredDistance", false ); this->m_Parameters.SetBool( "UseImageSpacing", true ); - this->m_Parameters.SetSelectedChoice( "OutputResolution", "float" ); } // ------------------------------------------------------------------------- @@ -44,9 +45,8 @@ void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); - cpPlugins_Demangle_ImageScalars( o, _GD0, 2 ); - else cpPlugins_Demangle_ImageScalars( o, _GD0, 3 ); - else this->_Error( "Invalid input image." ); + cpPlugins_Demangle_Image_ProcessDims( o, _GD0, ) + this->_Error( "Invalid input image dimension." ); } // ------------------------------------------------------------------------- @@ -54,21 +54,31 @@ template< class _TImage > void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter:: _GD0( _TImage* image ) { - typedef itk::Image< float, _TImage::ImageDimension > _TFDmap; - typedef itk::Image< double, _TImage::ImageDimension > _TDDmap; + cpPlugins_Demangle_Image_ScalarPixels( 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" ); - if( out_res == "float" ) this->_GD1< _TImage, _TFDmap >( image ); - else if( out_res == "double" ) this->_GD1< _TImage, _TDDmap >( image ); - else this->_Error( "Output resolution not supported." ); +#ifdef cpPlugins_CONFIG_REAL_TYPES_float + if( out_res == "float" ) this->_GD2< _TImage, float >( image ); +#endif // cpPlugins_CONFIG_REAL_TYPES_float +#ifdef cpPlugins_CONFIG_REAL_TYPES_double + if( out_res == "double" ) this->_GD2< _TImage, double >( image ); +#endif // cpPlugins_CONFIG_REAL_TYPES_double } // ------------------------------------------------------------------------- -template< class _TImage, class _TDMap > +template< class _TImage, class _TScalar > void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter:: -_GD1( _TImage* image ) +_GD2( _TImage* image ) { + typedef itk::Image< _TScalar, _TImage::ImageDimension > _TDMap; typedef itk::SignedMaurerDistanceMapImageFilter< _TImage, _TDMap > _TFilter;