1 #include <ImageDistanceMaps/BinaryContourImageFilter.h>
2 #include <cpPlugins/DataObjects/Image.h>
3 #include <cpPlugins/DataObjects/Image_Demanglers.h>
5 #include <itkBinaryContourImageFilter.h>
7 // -------------------------------------------------------------------------
8 cpPluginsImageDistanceMaps::BinaryContourImageFilter::
9 BinaryContourImageFilter( )
12 typedef cpPlugins::DataObjects::Image _TImage;
14 this->_ConfigureInput< _TImage >( "Input", true, false );
15 this->_ConfigureOutput< _TImage >( "Output" );
17 this->m_Parameters.ConfigureAsReal( "BackgroundValue", 0 );
18 this->m_Parameters.ConfigureAsReal( "ForegroundValue", 1 );
19 this->m_Parameters.ConfigureAsBool( "FullyConnected", false );
22 // -------------------------------------------------------------------------
23 cpPluginsImageDistanceMaps::BinaryContourImageFilter::
24 ~BinaryContourImageFilter( )
28 // -------------------------------------------------------------------------
29 void cpPluginsImageDistanceMaps::BinaryContourImageFilter::
32 auto o = this->GetInputData( "Input" );
33 cpPlugins_Demangle_Image_VisualDims_1( o, _GD0 )
34 this->_Error( "Invalid input image dimension." );
37 // -------------------------------------------------------------------------
38 template< class _TImage >
39 void cpPluginsImageDistanceMaps::BinaryContourImageFilter::
40 _GD0( _TImage* image )
42 cpPlugins_Demangle_Image_ScalarPixels_1( image, _GD1, _TImage::ImageDimension )
43 this->_Error( "Invalid input image pixel type." );
46 // -------------------------------------------------------------------------
47 template< class _TImage >
48 void cpPluginsImageDistanceMaps::BinaryContourImageFilter::
49 _GD1( _TImage* image )
52 itk::BinaryContourImageFilter< _TImage, _TImage >
56 double b = this->m_Parameters.GetReal( "BackgroundValue" );
57 double f = this->m_Parameters.GetReal( "ForegroundValue" );
58 double c = this->m_Parameters.GetBool( "FullyConnected" );
61 _TFilter* filter = this->_CreateITK< _TFilter >( );
62 filter->SetInput( image );
63 filter->SetBackgroundValue( ( typename _TImage::PixelType )( b ) );
64 filter->SetForegroundValue( ( typename _TImage::PixelType )( f ) );
65 filter->SetFullyConnected( c );
69 this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );