1 #include <cpPluginsImageFilters/BinaryContourImageFilter.h>
2 #include <cpPlugins/Image.h>
3 #include <cpPlugins_Instances/DistanceMapFilters.h>
5 // -------------------------------------------------------------------------
6 cpPluginsImageFilters::BinaryContourImageFilter::
7 BinaryContourImageFilter( )
10 this->_AddInput( "Input" );
11 this->_AddOutput< cpPlugins::Image >( "Output" );
13 this->m_Parameters.ConfigureAsBool( "FullyConnected" );
14 this->m_Parameters.ConfigureAsReal( "BackgroundValue" );
15 this->m_Parameters.ConfigureAsReal( "ForegroundValue" );
16 std::vector< std::string > choices;
17 choices.push_back( "float" );
18 choices.push_back( "double" );
19 this->m_Parameters.ConfigureAsChoices( "OutputResolution", choices );
21 this->m_Parameters.SetBool( "FullyConnected", false );
22 this->m_Parameters.SetReal( "BackgroundValue", 0 );
23 this->m_Parameters.SetReal( "ForegroundValue", 1 );
24 this->m_Parameters.SetSelectedChoice( "OutputResolution", "float" );
27 // -------------------------------------------------------------------------
28 cpPluginsImageFilters::BinaryContourImageFilter::
29 ~BinaryContourImageFilter( )
33 // -------------------------------------------------------------------------
34 std::string cpPluginsImageFilters::BinaryContourImageFilter::
37 auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
38 std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
39 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
43 // -------------------------------------------------------------------------
44 template< class _TImage >
45 std::string cpPluginsImageFilters::BinaryContourImageFilter::
46 _GD0( _TImage* image )
51 this->m_Parameters.GetSelectedChoice( "OutputResolution" );
52 if( out_res == "float" )
54 this->_GD1< _TImage, itk::Image< float, _TImage::ImageDimension > >(
58 else // if( out_res == "double" )
60 this->_GD1< _TImage, itk::Image< double, _TImage::ImageDimension > >(
67 "ImageFilters::BinaryContourImageFilter: No valid input image."
71 // -------------------------------------------------------------------------
72 template< class _TImage, class _TContourImage >
73 std::string cpPluginsImageFilters::BinaryContourImageFilter::
74 _GD1( _TImage* image )
76 typedef itk::BinaryContourImageFilter< _TImage, _TContourImage > _F;
79 bool fc = this->m_Parameters.GetBool( "FullyConnected" );
80 double bv = this->m_Parameters.GetReal( "BackgroundValue" );
81 double fv = this->m_Parameters.GetReal( "ForegroundValue" );
84 _F* filter = this->_CreateITK< _F >( );
85 filter->SetInput( image );
86 filter->SetFullyConnected( fc );
87 filter->SetBackgroundValue( bv );
88 filter->SetForegroundValue( fv );
92 this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );