1 #include <ImageThresholdFilters/UnaryThresholdImageFilter.h>
2 #include <cpPlugins/DataObjects/Image.h>
3 #include <cpPlugins/DataObjects/Image_Demanglers.h>
5 #include <cpExtensions/Algorithms/UnaryThresholdImageFilter.h>
7 // -------------------------------------------------------------------------
8 cpPluginsImageThresholdFilters::UnaryThresholdImageFilter::
9 UnaryThresholdImageFilter( )
12 typedef cpPlugins::DataObjects::Image _TImage;
13 this->_ConfigureInput< _TImage >( "Input", true, false );
14 this->_ConfigureOutput< _TImage >( "Output" );
16 this->m_Parameters.ConfigureAsReal( "Threshold", 0 );
17 this->m_Parameters.ConfigureAsReal( "InsideValue", 1 );
18 this->m_Parameters.ConfigureAsReal( "OutsideValue", 0 );
19 this->m_Parameters.ConfigureAsBool( "Strict", false );
22 // -------------------------------------------------------------------------
23 cpPluginsImageThresholdFilters::UnaryThresholdImageFilter::
24 ~UnaryThresholdImageFilter( )
28 // -------------------------------------------------------------------------
29 void cpPluginsImageThresholdFilters::UnaryThresholdImageFilter::
32 auto o = this->GetInputData( "Input" );
33 cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
34 this->_Error( "Invalid input image." );
37 // -------------------------------------------------------------------------
38 template< class _TImage >
39 void cpPluginsImageThresholdFilters::UnaryThresholdImageFilter::
40 _GD0( _TImage* image )
43 cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >
47 _TFilter* filter = this->_CreateITK< _TFilter >( );
48 filter->SetInput( image );
49 filter->SetThreshold( this->m_Parameters.GetReal( "Threshold" ) );
50 filter->SetInsideValue( this->m_Parameters.GetReal( "InsideValue" ) );
51 filter->SetOutsideValue( this->m_Parameters.GetReal( "OutsideValue" ) );
52 filter->SetStrict( this->m_Parameters.GetBool( "Strict" ) );
56 this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );