1 #include <ITKDistanceMapFilters/SignedMaurerDistanceMapImageFilter.h>
2 #include <cpInstances/Image.h>
4 #include <itkSignedMaurerDistanceMapImageFilter.h>
6 // -------------------------------------------------------------------------
7 cpPluginsITKDistanceMapFilters::SignedMaurerDistanceMapImageFilter::
8 SignedMaurerDistanceMapImageFilter( )
11 typedef cpInstances::Image _TImage;
13 this->_ConfigureInput< _TImage >( "Input", true, false );
14 this->_ConfigureOutput< _TImage >( "Output" );
16 this->m_Parameters.ConfigureAsReal( "BackgroundValue", 0 );
17 this->m_Parameters.ConfigureAsBool( "InsideIsPositive", true );
18 this->m_Parameters.ConfigureAsBool( "SquaredDistance", false );
19 this->m_Parameters.ConfigureAsBool( "UseImageSpacing", true );
21 std::vector< std::string > choices;
22 #ifdef cpPlugins_CONFIG_REAL_TYPES_float
23 choices.push_back( "float" );
24 #endif // cpPlugins_CONFIG_REAL_TYPES_float
25 #ifdef cpPlugins_CONFIG_REAL_TYPES_double
26 choices.push_back( "double" );
27 #endif // cpPlugins_CONFIG_REAL_TYPES_double
28 this->m_Parameters.ConfigureAsChoices( "OutputResolution", choices );
31 // -------------------------------------------------------------------------
32 cpPluginsITKDistanceMapFilters::SignedMaurerDistanceMapImageFilter::
33 ~SignedMaurerDistanceMapImageFilter( )
37 // -------------------------------------------------------------------------
38 void cpPluginsITKDistanceMapFilters::SignedMaurerDistanceMapImageFilter::
41 auto o = this->GetInputData( "Input" );
42 cpPlugins_Demangle_Image_ScalarPixels_VisualDims_1( o, _GD0 )
43 this->_Error( "Invalid input image dimension." );
46 // -------------------------------------------------------------------------
47 template< class _TImage >
48 void cpPluginsITKDistanceMapFilters::SignedMaurerDistanceMapImageFilter::
49 _GD0( _TImage* image )
52 this->m_Parameters.GetSelectedChoice( "OutputResolution" );
53 #ifdef cpPlugins_CONFIG_REAL_TYPES_float
54 if( out_res == "float" ) this->_GD1< _TImage, float >( image );
55 #endif // cpPlugins_CONFIG_REAL_TYPES_float
56 #ifdef cpPlugins_CONFIG_REAL_TYPES_double
57 if( out_res == "double" ) this->_GD1< _TImage, double >( image );
58 #endif // cpPlugins_CONFIG_REAL_TYPES_double
61 // -------------------------------------------------------------------------
62 template< class _TImage, class _TScalar >
63 void cpPluginsITKDistanceMapFilters::SignedMaurerDistanceMapImageFilter::
64 _GD1( _TImage* image )
66 typedef itk::Image< _TScalar, _TImage::ImageDimension > _TDMap;
68 itk::SignedMaurerDistanceMapImageFilter< _TImage, _TDMap >
72 double bv = this->m_Parameters.GetReal( "BackgroundValue" );
73 bool pi = this->m_Parameters.GetBool( "InsideIsPositive" );
74 bool sd = this->m_Parameters.GetBool( "SquaredDistance" );
75 bool us = this->m_Parameters.GetBool( "UseImageSpacing" );
78 _TFilter* filter = this->_CreateITK< _TFilter >( );
79 filter->SetInput( image );
80 filter->SetBackgroundValue( ( typename _TImage::PixelType )( bv ) );
81 filter->SetInsideIsPositive( pi );
82 filter->SetSquaredDistance( sd );
83 filter->SetUseImageSpacing( us );
87 this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );