]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx
...
[cpPlugins.git] / lib / cpPlugins / Plugins / BasicFilters / BinaryThresholdImageFilter.cxx
index 21df227a941c125d54a774f0f676d81fb41d6030..af2c26ae01d11f165081115cf1dfdc5b6b558d0d 100644 (file)
@@ -8,14 +8,18 @@ cpPlugins::BasicFilters::BinaryThresholdImageFilter::
 BinaryThresholdImageFilter( )
   : Superclass( )
 {
-  this->SetNumberOfInputs( 1 );
-  this->SetNumberOfOutputs( 1 );
-  this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
+  this->_AddInput( "Input" );
+  this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
 
-  this->m_Parameters->ConfigureAsReal( "LowerThresholdValue", 0 );
-  this->m_Parameters->ConfigureAsReal( "UpperThresholdValue", 0 );
-  this->m_Parameters->ConfigureAsUint( "InsideValue", 255 );
-  this->m_Parameters->ConfigureAsUint( "OutsideValue", 1 );
+  this->m_Parameters->ConfigureAsReal( "LowerThresholdValue" );
+  this->m_Parameters->ConfigureAsReal( "UpperThresholdValue" );
+  this->m_Parameters->ConfigureAsUint( "InsideValue" );
+  this->m_Parameters->ConfigureAsUint( "OutsideValue" );
+
+  this->m_Parameters->SetReal( "LowerThresholdValue", 0 );
+  this->m_Parameters->SetReal( "UpperThresholdValue", 10000 );
+  this->m_Parameters->SetUint( "InsideValue", 1 );
+  this->m_Parameters->SetUint( "OutsideValue", 0 );
 }
 
 // -------------------------------------------------------------------------
@@ -28,11 +32,7 @@ cpPlugins::BasicFilters::BinaryThresholdImageFilter::
 std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter::
 _GenerateData( )
 {
-  cpPlugins::Interface::Image* image =
-    this->GetInput< cpPlugins::Interface::Image >( 0 );
-  if( image == NULL )
-    return( "BinaryThresholdImageFilter: No input image." );
-
+  auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" );
   itk::DataObject* itk_image = NULL;
   std::string r = "";
   cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
@@ -66,8 +66,8 @@ _RealGD( itk::DataObject* image )
   // Get parameters
   //unsigned int bins =
   //  this->m_Parameters.GetValueAsUint( "NumberOfHistogramBins" );
-  _IP lower_val = _IP( this->m_Parameters->GetReal( "LowerValue" ) );
-  _IP upper_val = _IP( this->m_Parameters->GetReal( "UpperValue" ) );
+  _IP lower_val = _IP( this->m_Parameters->GetReal( "LowerThresholdValue" ) );
+  _IP upper_val = _IP( this->m_Parameters->GetReal( "UpperThresholdValue" ) );
   _OP in_val = _OP( this->m_Parameters->GetUint( "InsideValue" ) );
   _OP out_val = _OP( this->m_Parameters->GetUint( "OutsideValue" ) );
 
@@ -81,15 +81,9 @@ _RealGD( itk::DataObject* image )
   filter->Update( );
 
   // Connect output
-  cpPlugins::Interface::Image* out =
-    this->GetOutput< cpPlugins::Interface::Image >( 0 );
-  if( out != NULL )
-  {
-    out->SetITK< O >( filter->GetOutput( ) );
-    return( "" );
-  }
-  else
-    return( "BinaryThresholdImageFilter: output not correctly created." );
+  auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" );
+  out->SetITK( filter->GetOutput( ) );
+  return( "" );
 }
 
 // eof - $RCSfile$