]> Creatis software - cpPlugins.git/blob - plugins/ImageThresholdFilters/BinaryThresholdImageFilter.cxx
12537737b1f1c581a6389aca2646c4a9a4d63ba5
[cpPlugins.git] / plugins / ImageThresholdFilters / BinaryThresholdImageFilter.cxx
1 #include <ImageThresholdFilters/BinaryThresholdImageFilter.h>
2 #include <cpPlugins/DataObjects/Image.h>
3
4 #include <itkBinaryThresholdImageFilter.h>
5
6 // -------------------------------------------------------------------------
7 cpPluginsImageThresholdFilters::BinaryThresholdImageFilter::
8 BinaryThresholdImageFilter( )
9   : Superclass( )
10 {
11   typedef cpPlugins::DataObjects::Image _TImage;
12   this->_ConfigureInput< _TImage >( "Input", true, false );
13   this->_ConfigureOutput< _TImage >( "Output" );
14
15   this->m_Parameters.ConfigureAsReal( "LowerThresholdValue" );
16   this->m_Parameters.ConfigureAsReal( "UpperThresholdValue" );
17   this->m_Parameters.ConfigureAsUint( "InsideValue" );
18   this->m_Parameters.ConfigureAsUint( "OutsideValue" );
19
20   this->m_Parameters.SetReal( "LowerThresholdValue", 0 );
21   this->m_Parameters.SetReal( "UpperThresholdValue", 10000 );
22   this->m_Parameters.SetUint( "InsideValue", 1 );
23   this->m_Parameters.SetUint( "OutsideValue", 0 );
24 }
25
26 // -------------------------------------------------------------------------
27 cpPluginsImageThresholdFilters::BinaryThresholdImageFilter::
28 ~BinaryThresholdImageFilter( )
29 {
30 }
31
32 // -------------------------------------------------------------------------
33 void cpPluginsImageThresholdFilters::BinaryThresholdImageFilter::
34 _GenerateData( )
35 {
36   /* TODO
37      auto o = this->GetInputData( "Input" );
38      cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 );
39      else this->_Error( "Invalid input image." );
40   */
41 }
42
43 // -------------------------------------------------------------------------
44 template< class _TImage >
45 void cpPluginsImageThresholdFilters::BinaryThresholdImageFilter::
46 _GD0( _TImage* image )
47 {
48   /* TODO
49      typedef unsigned char _TBin;
50      typedef itk::Image< unsigned char, _TImage::ImageDimension > _TBinImage;
51      typedef itk::BinaryThresholdImageFilter< _TImage, _TBinImage > _TFilter;
52      typedef typename _TImage::PixelType _TPixel;
53
54      // Get parameters
55      _TPixel lt = _TPixel( this->m_Parameters.GetReal( "LowerThresholdValue" ) );
56      _TPixel ut = _TPixel( this->m_Parameters.GetReal( "UpperThresholdValue" ) );
57      _TBin iv  = _TBin( this->m_Parameters.GetUint( "InsideValue" ) );
58      _TBin ov = _TBin( this->m_Parameters.GetUint( "OutsideValue" ) );
59
60      // Configure filter
61      _TFilter* filter = this->_CreateITK< _TFilter >( );
62      filter->SetInput( image );
63      filter->SetLowerThreshold( lt );
64      filter->SetUpperThreshold( ut );
65      filter->SetInsideValue( iv );
66      filter->SetOutsideValue( ov );
67      filter->Update( );
68
69      // Connect output
70      this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
71   */
72 }
73
74 // eof - $RCSfile$