]> Creatis software - cpPlugins.git/blob - plugins/ImageThresholdFilters/UnaryThresholdImageFilter.cxx
...
[cpPlugins.git] / plugins / ImageThresholdFilters / UnaryThresholdImageFilter.cxx
1 #include <ImageThresholdFilters/UnaryThresholdImageFilter.h>
2 #include <cpPlugins/DataObjects/Image.h>
3 #include <cpPlugins/DataObjects/Image_Demanglers.h>
4
5 #include <cpExtensions/Algorithms/UnaryThresholdImageFilter.h>
6
7 // -------------------------------------------------------------------------
8 cpPluginsImageThresholdFilters::UnaryThresholdImageFilter::
9 UnaryThresholdImageFilter( )
10   : Superclass( )
11 {
12   typedef cpPlugins::DataObjects::Image _TImage;
13   this->_ConfigureInput< _TImage >( "Input", true, false );
14   this->_ConfigureOutput< _TImage >( "Output" );
15
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 );
20 }
21
22 // -------------------------------------------------------------------------
23 cpPluginsImageThresholdFilters::UnaryThresholdImageFilter::
24 ~UnaryThresholdImageFilter( )
25 {
26 }
27
28 // -------------------------------------------------------------------------
29 void cpPluginsImageThresholdFilters::UnaryThresholdImageFilter::
30 _GenerateData( )
31 {
32   auto o = this->GetInputData( "Input" );
33   cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
34     this->_Error( "Invalid input image." );
35 }
36
37 // -------------------------------------------------------------------------
38 template< class _TImage >
39 void cpPluginsImageThresholdFilters::UnaryThresholdImageFilter::
40 _GD0( _TImage* image )
41 {
42   typedef
43     cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >
44     _TFilter;
45
46   // Configure filter
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" ) );
53   filter->Update( );
54
55   // Connect output
56   this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
57 }
58
59 // eof - $RCSfile$