1 #include <ImageDistanceMaps/SignedMaurerDistanceMapImageFilter.h>
2 #include <cpPlugins/DataObjects/Image.h>
3 #include <cpPlugins/DataObjects/Image_Demanglers.h>
5 #include <itkSignedMaurerDistanceMapImageFilter.h>
7 // -------------------------------------------------------------------------
8 cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter::
9 SignedMaurerDistanceMapImageFilter( )
12 typedef cpPlugins::DataObjects::Image _TImage;
14 this->_ConfigureInput< _TImage >( "Input", true, false );
15 this->_ConfigureOutput< _TImage >( "Output" );
17 this->m_Parameters.ConfigureAsReal( "BackgroundValue", 0 );
18 this->m_Parameters.ConfigureAsBool( "InsideIsPositive", true );
19 this->m_Parameters.ConfigureAsBool( "SquaredDistance", false );
20 this->m_Parameters.ConfigureAsBool( "UseImageSpacing", true );
22 std::vector< std::string > choices;
23 #ifdef cpPlugins_CONFIG_REAL_TYPES_float
24 choices.push_back( "float" );
25 #endif // cpPlugins_CONFIG_REAL_TYPES_float
26 #ifdef cpPlugins_CONFIG_REAL_TYPES_double
27 choices.push_back( "double" );
28 #endif // cpPlugins_CONFIG_REAL_TYPES_double
29 this->m_Parameters.ConfigureAsChoices( "OutputResolution", choices );
32 // -------------------------------------------------------------------------
33 cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter::
34 ~SignedMaurerDistanceMapImageFilter( )
38 // -------------------------------------------------------------------------
39 void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter::
42 auto o = this->GetInputData( "Input" );
43 cpPlugins_Demangle_Image_ScalarPixels_VisualDims_1( o, _GD0 )
44 this->_Error( "Invalid input image dimension." );
47 // -------------------------------------------------------------------------
48 template< class _TImage >
49 void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter::
50 _GD0( _TImage* image )
53 this->m_Parameters.GetSelectedChoice( "OutputResolution" );
54 #ifdef cpPlugins_CONFIG_REAL_TYPES_float
55 if( out_res == "float" ) this->_GD1< _TImage, float >( image );
56 #endif // cpPlugins_CONFIG_REAL_TYPES_float
57 #ifdef cpPlugins_CONFIG_REAL_TYPES_double
58 if( out_res == "double" ) this->_GD1< _TImage, double >( image );
59 #endif // cpPlugins_CONFIG_REAL_TYPES_double
62 // -------------------------------------------------------------------------
63 template< class _TImage, class _TScalar >
64 void cpPluginsImageDistanceMaps::SignedMaurerDistanceMapImageFilter::
65 _GD1( _TImage* image )
67 typedef itk::Image< _TScalar, _TImage::ImageDimension > _TDMap;
69 itk::SignedMaurerDistanceMapImageFilter< _TImage, _TDMap >
73 double bv = this->m_Parameters.GetReal( "BackgroundValue" );
74 bool pi = this->m_Parameters.GetBool( "InsideIsPositive" );
75 bool sd = this->m_Parameters.GetBool( "SquaredDistance" );
76 bool us = this->m_Parameters.GetBool( "UseImageSpacing" );
79 _TFilter* filter = this->_CreateITK< _TFilter >( );
80 filter->SetInput( image );
81 filter->SetBackgroundValue( ( typename _TImage::PixelType )( bv ) );
82 filter->SetInsideIsPositive( pi );
83 filter->SetSquaredDistance( sd );
84 filter->SetUseImageSpacing( us );
88 this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );