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 choices.push_back( "float" );
23 choices.push_back( "double" );
24 this->m_Parameters.ConfigureAsChoices( "OutputResolution", choices );
27 // -------------------------------------------------------------------------
28 cpPluginsITKDistanceMapFilters::SignedMaurerDistanceMapImageFilter::
29 ~SignedMaurerDistanceMapImageFilter( )
33 // -------------------------------------------------------------------------
34 void cpPluginsITKDistanceMapFilters::SignedMaurerDistanceMapImageFilter::
37 auto o = this->GetInputData( "Input" );
38 cpPlugins_Demangle_Image_ScalarPixels_VisualDims_1( o, _GD0 )
39 this->_Error( "Invalid input image dimension." );
42 // -------------------------------------------------------------------------
43 template< class _TImage >
44 void cpPluginsITKDistanceMapFilters::SignedMaurerDistanceMapImageFilter::
45 _GD0( _TImage* image )
48 this->m_Parameters.GetSelectedChoice( "OutputResolution" );
49 if( out_res == "float" ) this->_GD1< _TImage, float >( image );
50 if( out_res == "double" ) this->_GD1< _TImage, double >( image );
53 // -------------------------------------------------------------------------
54 template< class _TImage, class _TScalar >
55 void cpPluginsITKDistanceMapFilters::SignedMaurerDistanceMapImageFilter::
56 _GD1( _TImage* image )
58 typedef itk::Image< _TScalar, _TImage::ImageDimension > _TDMap;
60 itk::SignedMaurerDistanceMapImageFilter< _TImage, _TDMap >
64 double bv = this->m_Parameters.GetReal( "BackgroundValue" );
65 bool pi = this->m_Parameters.GetBool( "InsideIsPositive" );
66 bool sd = this->m_Parameters.GetBool( "SquaredDistance" );
67 bool us = this->m_Parameters.GetBool( "UseImageSpacing" );
70 _TFilter* filter = this->_CreateITK< _TFilter >( );
71 filter->SetInput( image );
72 filter->SetBackgroundValue( ( typename _TImage::PixelType )( bv ) );
73 filter->SetInsideIsPositive( pi );
74 filter->SetSquaredDistance( sd );
75 filter->SetUseImageSpacing( us );
79 this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );