1 #include <cpPluginsImageFilters/SignedMaurerDistanceMapImageFilter.h>
2 #include <cpPlugins/Image.h>
3 #include <cpPlugins_Instances/DistanceMapFilters.h>
5 // -------------------------------------------------------------------------
6 cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
7 SignedMaurerDistanceMapImageFilter( )
10 this->_AddInput( "Input" );
11 this->_AddOutput< cpPlugins::Image >( "Output" );
13 this->m_Parameters.ConfigureAsReal( "BackgroundValue" );
14 this->m_Parameters.ConfigureAsBool( "InsideIsPositive" );
15 this->m_Parameters.ConfigureAsBool( "SquaredDistance" );
16 this->m_Parameters.ConfigureAsBool( "UseImageSpacing" );
18 std::vector< std::string > choices;
19 choices.push_back( "float" );
20 choices.push_back( "double" );
21 this->m_Parameters.ConfigureAsChoices( "OutputResolution", choices );
23 this->m_Parameters.SetReal( "BackgroundValue", 0 );
24 this->m_Parameters.SetBool( "InsideIsPositive", true );
25 this->m_Parameters.SetBool( "SquaredDistance", false );
26 this->m_Parameters.SetBool( "UseImageSpacing", true );
27 this->m_Parameters.SetSelectedChoice( "OutputResolution", "float" );
30 // -------------------------------------------------------------------------
31 cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
32 ~SignedMaurerDistanceMapImageFilter( )
36 // -------------------------------------------------------------------------
37 std::string cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
40 auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
41 std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
42 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
46 // -------------------------------------------------------------------------
47 template< class _TImage >
48 std::string cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
49 _GD0( _TImage* image )
54 this->m_Parameters.GetSelectedChoice( "OutputResolution" );
55 if( out_res == "float" )
57 this->_GD1< _TImage, itk::Image< float, _TImage::ImageDimension > >( image )
59 else if( out_res == "double" )
61 this->_GD1< _TImage, itk::Image< double, _TImage::ImageDimension > >( image )
64 return( "ImageFilters::SignedMaurerDistanceMapImageFilter: Output resolution not supported." );
68 "ImageFilters::SignedMaurerDistanceMapImageFilter: No valid input image."
72 // -------------------------------------------------------------------------
73 template< class _TImage, class _TDMap >
74 std::string cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
75 _GD1( _TImage* image )
77 typedef itk::SignedMaurerDistanceMapImageFilter< _TImage, _TDMap > _F;
80 double back_value = this->m_Parameters.GetReal( "BackgroundValue" );
81 bool pos_inside = this->m_Parameters.GetBool( "InsideIsPositive" );
82 bool sqr_dist = this->m_Parameters.GetBool( "SquaredDistance" );
83 bool use_spac = this->m_Parameters.GetBool( "UseImageSpacing" );
86 _F* filter = this->_CreateITK< _F >( );
87 filter->SetInput( image );
88 filter->SetBackgroundValue( ( typename _TImage::PixelType )( back_value ) );
89 filter->SetInsideIsPositive( pos_inside );
90 filter->SetSquaredDistance( sqr_dist );
91 filter->SetUseImageSpacing( use_spac );
95 this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );