1 #include <plugins/ImageThresholdFilters/UnaryThresholdImageFilter.h>
2 #include <cpPlugins/DataObjects/Image.h>
4 #include <cpExtensions/Algorithms/UnaryThresholdImageFilter.h>
5 #include <cpExtensions/Algorithms/UnaryThresholdImageFilter.hxx>
6 #include <itkUnaryFunctorImageFilter.hxx>
8 // -------------------------------------------------------------------------
9 cpPluginsImageThresholdFilters::UnaryThresholdImageFilter::
10 UnaryThresholdImageFilter( )
13 this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input", true, false );
14 this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" );
16 this->m_Parameters.ConfigureAsReal( "Threshold" );
17 this->m_Parameters.ConfigureAsReal( "InsideValue" );
18 this->m_Parameters.ConfigureAsReal( "OutsideValue" );
19 this->m_Parameters.ConfigureAsBool( "Strict" );
21 this->m_Parameters.SetReal( "Threshold", 0 );
22 this->m_Parameters.SetReal( "InsideValue", 1 );
23 this->m_Parameters.SetReal( "OutsideValue", 0 );
24 this->m_Parameters.SetBool( "Strict", false );
27 // -------------------------------------------------------------------------
28 cpPluginsImageThresholdFilters::UnaryThresholdImageFilter::
29 ~UnaryThresholdImageFilter( )
33 // -------------------------------------------------------------------------
34 void cpPluginsImageThresholdFilters::UnaryThresholdImageFilter::
37 auto o = this->GetInputData( "Input" );
38 cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 );
39 else this->_Error( "Invalid input image." );
42 // -------------------------------------------------------------------------
43 template< class _TImage >
44 void cpPluginsImageThresholdFilters::UnaryThresholdImageFilter::
45 _GD0( _TImage* image )
48 cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >
52 _TFilter* filter = this->_CreateITK< _TFilter >( );
53 filter->SetInput( image );
54 filter->SetThreshold( this->m_Parameters.GetReal( "Threshold" ) );
55 filter->SetInsideValue( this->m_Parameters.GetReal( "InsideValue" ) );
56 filter->SetOutsideValue( this->m_Parameters.GetReal( "OutsideValue" ) );
57 filter->SetStrict( this->m_Parameters.GetBool( "Strict" ) );
61 this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );