1 #include <cpPluginsImageFilters/SignedMaurerDistanceMapImageFilter.h>
2 #include <cpPlugins/Image.h>
4 #include <itkSignedMaurerDistanceMapImageFilter.h>
5 #include <itkSignedMaurerDistanceMapImageFilter.hxx>
6 #include <itkBinaryThresholdImageFilter.hxx>
7 #include <itkImageToImageFilter.hxx>
8 #include <itkInPlaceImageFilter.hxx>
9 #include <itkUnaryFunctorImageFilter.hxx>
10 #include <itkBinaryContourImageFilter.hxx>
12 // -------------------------------------------------------------------------
13 cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
14 SignedMaurerDistanceMapImageFilter( )
17 this->_AddInput( "Input" );
18 this->_AddOutput< cpPlugins::Image >( "Output" );
20 this->m_Parameters.ConfigureAsReal( "BackgroundValue" );
21 this->m_Parameters.ConfigureAsBool( "InsideIsPositive" );
22 this->m_Parameters.ConfigureAsBool( "SquaredDistance" );
23 this->m_Parameters.ConfigureAsBool( "UseImageSpacing" );
25 std::vector< std::string > choices;
26 choices.push_back( "float" );
27 choices.push_back( "double" );
28 this->m_Parameters.ConfigureAsChoices( "OutputResolution", choices );
30 this->m_Parameters.SetReal( "BackgroundValue", 0 );
31 this->m_Parameters.SetBool( "InsideIsPositive", true );
32 this->m_Parameters.SetBool( "SquaredDistance", false );
33 this->m_Parameters.SetBool( "UseImageSpacing", true );
34 this->m_Parameters.SetSelectedChoice( "OutputResolution", "float" );
37 // -------------------------------------------------------------------------
38 cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
39 ~SignedMaurerDistanceMapImageFilter( )
43 // -------------------------------------------------------------------------
44 std::string cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
47 auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
48 std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
49 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
53 // -------------------------------------------------------------------------
55 std::string cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
61 this->m_Parameters.GetSelectedChoice( "OutputResolution" );
62 if( out_res == "float" )
64 this->_GD1< I, itk::Image< float, I::ImageDimension > >( image )
66 else if( out_res == "double" )
68 this->_GD1< I, itk::Image< double, I::ImageDimension > >( image )
71 return( "ImageFilters::SignedMaurerDistanceMapImageFilter: Output resolution not supported." );
75 "ImageFilters::SignedMaurerDistanceMapImageFilter: No valid input image."
79 // -------------------------------------------------------------------------
80 template< class I, class O >
81 std::string cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter::
84 typedef itk::SignedMaurerDistanceMapImageFilter< I, O > _F;
87 double back_value = this->m_Parameters.GetReal( "BackgroundValue" );
88 bool pos_inside = this->m_Parameters.GetBool( "InsideIsPositive" );
89 bool sqr_dist = this->m_Parameters.GetBool( "SquaredDistance" );
90 bool use_spac = this->m_Parameters.GetBool( "UseImageSpacing" );
93 _F* filter = this->_CreateITK< _F >( );
94 filter->SetInput( image );
95 filter->SetBackgroundValue( ( typename I::PixelType )( back_value ) );
96 filter->SetInsideIsPositive( pos_inside );
97 filter->SetSquaredDistance( sqr_dist );
98 filter->SetUseImageSpacing( use_spac );
102 this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );