1 #include <plugins/ImageFilters/UnaryThresholdImageFilter.h>
2 #include <cpPlugins/Image.h>
3 #include <cpPlugins_Instances_ThresholdFilters.h>
5 // -------------------------------------------------------------------------
6 cpPluginsImageFilters::UnaryThresholdImageFilter::
7 UnaryThresholdImageFilter( )
10 this->_AddInput( "Input" );
11 this->_AddOutput< cpPlugins::Image >( "Output" );
13 this->m_Parameters.ConfigureAsReal( "Threshold" );
14 this->m_Parameters.ConfigureAsReal( "InsideValue" );
15 this->m_Parameters.ConfigureAsReal( "OutsideValue" );
16 this->m_Parameters.ConfigureAsBool( "Strict" );
18 this->m_Parameters.SetReal( "Threshold", 0 );
19 this->m_Parameters.SetReal( "InsideValue", 1 );
20 this->m_Parameters.SetReal( "OutsideValue", 0 );
21 this->m_Parameters.SetBool( "Strict", false );
24 // -------------------------------------------------------------------------
25 cpPluginsImageFilters::UnaryThresholdImageFilter::
26 ~UnaryThresholdImageFilter( )
30 // -------------------------------------------------------------------------
31 void cpPluginsImageFilters::UnaryThresholdImageFilter::
34 auto image = this->GetInputData< itk::DataObject >( "Input" );
35 cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 );
36 else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 );
37 else this->_Error( "No valid input image." );
40 // -------------------------------------------------------------------------
41 template< class _TImage >
42 void cpPluginsImageFilters::UnaryThresholdImageFilter::
43 _GD0( _TImage* image )
46 cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >
49 _TFilter* filter = this->_CreateITK< _TFilter >( );
50 filter->SetInput( image );
51 filter->SetThreshold( this->m_Parameters.GetReal( "Threshold" ) );
52 filter->SetInsideValue( this->m_Parameters.GetReal( "InsideValue" ) );
53 filter->SetOutsideValue( this->m_Parameters.GetReal( "OutsideValue" ) );
54 filter->SetStrict( this->m_Parameters.GetBool( "Strict" ) );
56 this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );