]> Creatis software - cpPlugins.git/blob - plugins/ITKUnaryFunctorFilters/UnaryThresholdImageFilter.cxx
...
[cpPlugins.git] / plugins / ITKUnaryFunctorFilters / UnaryThresholdImageFilter.cxx
1 #include <ITKUnaryFunctorFilters/UnaryThresholdImageFilter.h>
2 #include <cpInstances/Image.h>
3
4 #include <cpExtensions/Algorithms/UnaryThresholdImageFilter.h>
5
6 // -------------------------------------------------------------------------
7 cpPluginsITKUnaryFunctorFilters::UnaryThresholdImageFilter::
8 UnaryThresholdImageFilter( )
9   : Superclass( )
10 {
11   this->_ConfigureInput< cpInstances::Image >( "Input", true, false );
12   this->_ConfigureOutput< cpInstances::Image >( "Output" );
13
14   this->m_Parameters.ConfigureAsReal( "Threshold", 0 );
15   this->m_Parameters.ConfigureAsReal( "InsideValue", 1 );
16   this->m_Parameters.ConfigureAsReal( "OutsideValue", 0 );
17   this->m_Parameters.ConfigureAsBool( "Strict", false );
18 }
19
20 // -------------------------------------------------------------------------
21 cpPluginsITKUnaryFunctorFilters::UnaryThresholdImageFilter::
22 ~UnaryThresholdImageFilter( )
23 {
24 }
25
26 // -------------------------------------------------------------------------
27 void cpPluginsITKUnaryFunctorFilters::UnaryThresholdImageFilter::
28 _GenerateData( )
29 {
30   auto o = this->GetInputData( "Input" );
31   cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
32     this->_Error( "Invalid input image." );
33 }
34
35 // -------------------------------------------------------------------------
36 template< class _TImage >
37 void cpPluginsITKUnaryFunctorFilters::UnaryThresholdImageFilter::
38 _GD0( _TImage* image )
39 {
40   typedef
41     cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >
42     _TFilter;
43
44   // Configure filter
45   _TFilter* filter = this->_CreateITK< _TFilter >( );
46   filter->SetInput( image );
47   filter->SetThreshold( this->m_Parameters.GetReal( "Threshold" ) );
48   filter->SetInsideValue( this->m_Parameters.GetReal( "InsideValue" ) );
49   filter->SetOutsideValue( this->m_Parameters.GetReal( "OutsideValue" ) );
50   filter->SetStrict( this->m_Parameters.GetBool( "Strict" ) );
51   filter->Update( );
52
53   // Connect output
54   this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
55 }
56
57 // eof - $RCSfile$