1 #include <cpPluginsImageFilters/SignedMaurerDistanceMapImageFilter.h>
2 #include <cpPlugins/Image.h>
3 #include <cpPlugins_ITKInstances/ImageFilters.h>
5 #include <itkSignedMaurerDistanceMapImageFilter.h>
6 #include <itkSignedMaurerDistanceMapImageFilter.hxx>
8 #include <itkBinaryThresholdImageFilter.hxx>
9 #include <itkImageToImageFilter.hxx>
10 #include <itkInPlaceImageFilter.hxx>
11 #include <itkUnaryFunctorImageFilter.hxx>
12 #include <itkBinaryContourImageFilter.hxx>
15 // -------------------------------------------------------------------------
16 cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
17 SignedMaurerDistanceMapImageFilter( )
20 this->_AddInput( "Input" );
21 this->_AddOutput< cpPlugins::Image >( "Output" );
23 this->m_Parameters.ConfigureAsReal( "BackgroundValue" );
24 this->m_Parameters.ConfigureAsBool( "InsideIsPositive" );
25 this->m_Parameters.ConfigureAsBool( "SquaredDistance" );
26 this->m_Parameters.ConfigureAsBool( "UseImageSpacing" );
28 std::vector< std::string > choices;
29 choices.push_back( "float" );
30 choices.push_back( "double" );
31 this->m_Parameters.ConfigureAsChoices( "OutputResolution", choices );
33 this->m_Parameters.SetReal( "BackgroundValue", 0 );
34 this->m_Parameters.SetBool( "InsideIsPositive", true );
35 this->m_Parameters.SetBool( "SquaredDistance", false );
36 this->m_Parameters.SetBool( "UseImageSpacing", true );
37 this->m_Parameters.SetSelectedChoice( "OutputResolution", "float" );
40 // -------------------------------------------------------------------------
41 cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
42 ~SignedMaurerDistanceMapImageFilter( )
46 // -------------------------------------------------------------------------
47 std::string cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
50 auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
51 std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
52 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
56 // -------------------------------------------------------------------------
57 template< class _TImage >
58 std::string cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
59 _GD0( _TImage* image )
64 this->m_Parameters.GetSelectedChoice( "OutputResolution" );
65 if( out_res == "float" )
67 this->_GD1< _TImage, itk::Image< float, _TImage::ImageDimension > >( image )
69 else if( out_res == "double" )
71 this->_GD1< _TImage, itk::Image< double, _TImage::ImageDimension > >( image )
74 return( "ImageFilters::SignedMaurerDistanceMapImageFilter: Output resolution not supported." );
78 "ImageFilters::SignedMaurerDistanceMapImageFilter: No valid input image."
82 // -------------------------------------------------------------------------
83 template< class _TImage, class _TDMap >
84 std::string cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
85 _GD1( _TImage* image )
87 typedef itk::SignedMaurerDistanceMapImageFilter< _TImage, _TDMap > _F;
90 double back_value = this->m_Parameters.GetReal( "BackgroundValue" );
91 bool pos_inside = this->m_Parameters.GetBool( "InsideIsPositive" );
92 bool sqr_dist = this->m_Parameters.GetBool( "SquaredDistance" );
93 bool use_spac = this->m_Parameters.GetBool( "UseImageSpacing" );
96 _F* filter = this->_CreateITK< _F >( );
97 filter->SetInput( image );
98 filter->SetBackgroundValue( ( typename _TImage::PixelType )( back_value ) );
99 filter->SetInsideIsPositive( pos_inside );
100 filter->SetSquaredDistance( sqr_dist );
101 filter->SetUseImageSpacing( use_spac );
105 this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );