1 #include <cpPluginsImageFilters/BinaryContourImageFilter.h>
2 #include <cpPlugins/Image.h>
3 #include <cpPlugins_ITKInstances/ImageFilters.h>
5 #include <itkProgressReporter.h>
6 #include <itkBinaryContourImageFilter.h>
7 #include <itkBinaryContourImageFilter.hxx>
9 // -------------------------------------------------------------------------
10 cpPluginsImageFilters::BinaryContourImageFilter::
11 BinaryContourImageFilter( )
14 this->_AddInput( "Input" );
15 this->_AddOutput< cpPlugins::Image >( "Output" );
17 this->m_Parameters.ConfigureAsBool( "FullyConnected" );
18 this->m_Parameters.ConfigureAsReal( "BackgroundValue" );
19 this->m_Parameters.ConfigureAsReal( "ForegroundValue" );
20 std::vector< std::string > choices;
21 choices.push_back( "float" );
22 choices.push_back( "double" );
23 this->m_Parameters.ConfigureAsChoices( "OutputResolution", choices );
25 this->m_Parameters.SetBool( "FullyConnected", false );
26 this->m_Parameters.SetReal( "BackgroundValue", 0 );
27 this->m_Parameters.SetReal( "ForegroundValue", 1 );
28 this->m_Parameters.SetSelectedChoice( "OutputResolution", "float" );
31 // -------------------------------------------------------------------------
32 cpPluginsImageFilters::BinaryContourImageFilter::
33 ~BinaryContourImageFilter( )
37 // -------------------------------------------------------------------------
38 std::string cpPluginsImageFilters::BinaryContourImageFilter::
41 auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
42 std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
43 if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
47 // -------------------------------------------------------------------------
48 template< class _TImage >
49 std::string cpPluginsImageFilters::BinaryContourImageFilter::
50 _GD0( _TImage* image )
55 this->m_Parameters.GetSelectedChoice( "OutputResolution" );
56 if( out_res == "float" )
58 this->_GD1< _TImage, itk::Image< float, _TImage::ImageDimension > >(
62 else // if( out_res == "double" )
64 this->_GD1< _TImage, itk::Image< double, _TImage::ImageDimension > >(
71 "ImageFilters::BinaryContourImageFilter: No valid input image."
75 // -------------------------------------------------------------------------
76 template< class _TImage, class _TContourImage >
77 std::string cpPluginsImageFilters::BinaryContourImageFilter::
78 _GD1( _TImage* image )
80 typedef itk::BinaryContourImageFilter< _TImage, _TContourImage > _F;
83 bool fc = this->m_Parameters.GetBool( "FullyConnected" );
84 double bv = this->m_Parameters.GetReal( "BackgroundValue" );
85 double fv = this->m_Parameters.GetReal( "ForegroundValue" );
88 _F* filter = this->_CreateITK< _F >( );
89 filter->SetInput( image );
90 filter->SetFullyConnected( fc );
91 filter->SetBackgroundValue( bv );
92 filter->SetForegroundValue( fv );
96 this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );