]> Creatis software - cpPlugins.git/blobdiff - plugins/ImageThresholdFilters/UnaryThresholdImageFilter.cxx
...
[cpPlugins.git] / plugins / ImageThresholdFilters / UnaryThresholdImageFilter.cxx
index cd16ed3a243ce3e6de71ef48346598eb1d006f0e..84aded188f6393ca83e75db72673b97e97617bac 100644 (file)
@@ -1,5 +1,6 @@
 #include <ImageThresholdFilters/UnaryThresholdImageFilter.h>
 #include <cpPlugins/DataObjects/Image.h>
+#include <cpPlugins/DataObjects/Image_Demanglers.h>
 
 #include <cpExtensions/Algorithms/UnaryThresholdImageFilter.h>
 
@@ -12,15 +13,10 @@ UnaryThresholdImageFilter( )
   this->_ConfigureInput< _TImage >( "Input", true, false );
   this->_ConfigureOutput< _TImage >( "Output" );
 
-  this->m_Parameters.ConfigureAsReal( "Threshold" );
-  this->m_Parameters.ConfigureAsReal( "InsideValue" );
-  this->m_Parameters.ConfigureAsReal( "OutsideValue" );
-  this->m_Parameters.ConfigureAsBool( "Strict" );
-
-  this->m_Parameters.SetReal( "Threshold", 0 );
-  this->m_Parameters.SetReal( "InsideValue", 1 );
-  this->m_Parameters.SetReal( "OutsideValue", 0 );
-  this->m_Parameters.SetBool( "Strict", false );
+  this->m_Parameters.ConfigureAsReal( "Threshold", 0 );
+  this->m_Parameters.ConfigureAsReal( "InsideValue", 1 );
+  this->m_Parameters.ConfigureAsReal( "OutsideValue", 0 );
+  this->m_Parameters.ConfigureAsBool( "Strict", false );
 }
 
 // -------------------------------------------------------------------------
@@ -33,11 +29,9 @@ cpPluginsImageThresholdFilters::UnaryThresholdImageFilter::
 void cpPluginsImageThresholdFilters::UnaryThresholdImageFilter::
 _GenerateData( )
 {
-  /* TODO
-     auto o = this->GetInputData( "Input" );
-     cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 );
-     else this->_Error( "Invalid input image." );
-  */
+  auto o = this->GetInputData( "Input" );
+  cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
+    this->_Error( "Invalid input image." );
 }
 
 // -------------------------------------------------------------------------
@@ -45,23 +39,21 @@ template< class _TImage >
 void cpPluginsImageThresholdFilters::UnaryThresholdImageFilter::
 _GD0( _TImage* image )
 {
-  /* TODO
-     typedef
-     cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >
-     _TFilter;
-
-     // Configure filter
-     _TFilter* filter = this->_CreateITK< _TFilter >( );
-     filter->SetInput( image );
-     filter->SetThreshold( this->m_Parameters.GetReal( "Threshold" ) );
-     filter->SetInsideValue( this->m_Parameters.GetReal( "InsideValue" ) );
-     filter->SetOutsideValue( this->m_Parameters.GetReal( "OutsideValue" ) );
-     filter->SetStrict( this->m_Parameters.GetBool( "Strict" ) );
-     filter->Update( );
-
-     // Connect output
-     this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
-  */
+  typedef
+    cpExtensions::Algorithms::UnaryThresholdImageFilter< _TImage >
+    _TFilter;
+
+  // Configure filter
+  _TFilter* filter = this->_CreateITK< _TFilter >( );
+  filter->SetInput( image );
+  filter->SetThreshold( this->m_Parameters.GetReal( "Threshold" ) );
+  filter->SetInsideValue( this->m_Parameters.GetReal( "InsideValue" ) );
+  filter->SetOutsideValue( this->m_Parameters.GetReal( "OutsideValue" ) );
+  filter->SetStrict( this->m_Parameters.GetBool( "Strict" ) );
+  filter->Update( );
+
+  // Connect output
+  this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
 }
 
 // eof - $RCSfile$