]> Creatis software - FrontAlgorithms.git/blobdiff - plugins/RegionGrowFunctors/BinaryThreshold.cxx
Mori is alivegit status!
[FrontAlgorithms.git] / plugins / RegionGrowFunctors / BinaryThreshold.cxx
index 05010ab4974efd39bdf28d082e29b491dcbe711e..f385e4aa3d4d3a3c62d0ad75519668ed4561f0bd 100644 (file)
@@ -1,7 +1,7 @@
 #include <RegionGrowFunctors/BinaryThreshold.h>
-#include <cpInstances/Image.h>
+#include <cpInstances/DataObjects/Image.h>
 
-#include <fpa/Image/Functors/RegionGrowBinaryThreshold.h>
+#include <fpa/Image/Functors/RegionGrow/BinaryThreshold.h>
 #include <itkConstNeighborhoodIterator.h>
 #include <vtkPolyData.h>
 
@@ -10,16 +10,16 @@ fpaPluginsRegionGrowFunctors::BinaryThreshold::
 BinaryThreshold( )
   : Superclass( )
 {
-  typedef cpPlugins::BaseObjects::DataObject _TData;
-  typedef cpInstances::Image _TImage;
+  typedef cpPlugins::Pipeline::DataObject _TData;
+  typedef cpInstances::DataObjects::Image _TImage;
 
   this->_ConfigureInput< _TImage >( "Input", true, false );
   this->_ConfigureInput< _TData >( "Seeds", false, false );
   this->_ConfigureOutput< _TData >( "Output" );
 
   this->m_Parameters.ConfigureAsUint( "Radius", 1 );
-  this->m_Parameters.ConfigureAsReal( "LowerThreshold", 0 );
-  this->m_Parameters.ConfigureAsReal( "UpperThreshold", 0 );
+  this->m_Parameters.ConfigureAsReal( "Lower", 0 );
+  this->m_Parameters.ConfigureAsReal( "Upper", 0 );
 }
 
 // -------------------------------------------------------------------------
@@ -44,7 +44,7 @@ _GD0( _TImage* image )
 {
   typedef itk::ConstNeighborhoodIterator< _TImage > _TInIt;
   typedef
-    fpa::Image::Functors::RegionGrowBinaryThreshold< _TImage >
+    fpa::Image::Functors::RegionGrow::BinaryThreshold< _TImage >
     _TFunctor;
   auto out = this->GetOutput( "Output" );
   auto f = out->GetITK< _TFunctor >( );
@@ -80,6 +80,7 @@ _GD0( _TImage* image )
 
     typename _TImage::SizeType r;
     r.Fill( this->m_Parameters.GetUint( "Radius" ) );
+
     _TInIt iIt( r, image, image->GetRequestedRegion( ) );
     double v_s1 = double( 0 );
     double v_s2 = double( 0 );
@@ -101,15 +102,20 @@ _GD0( _TImage* image )
       } // rof
 
     } // rof
+    double m = v_s1 / v_n;
     double s = ( v_s2 - ( ( v_s1 * v_s1 ) / v_n ) ) / ( v_n - double( 1 ) );
-    s = std::sqrt( s ) / double( 2 );
-    f->SetLowerThreshold( v_min );
-    f->SetUpperThreshold( v_max );
+    s = std::sqrt( s );
+    v_min = m - s;
+    v_max = m + s;
+    f->SetLower( v_min );
+    f->SetUpper( v_max );
+    this->m_Parameters.SetReal( "Lower", f->GetLower( ) );
+    this->m_Parameters.SetReal( "Upper", f->GetUpper( ) );
   }
   else
   {
-    f->SetLowerThreshold( this->m_Parameters.GetReal( "LowerThreshold" ) );
-    f->SetUpperThreshold( this->m_Parameters.GetReal( "UpperThreshold" ) );
+    f->SetLower( this->m_Parameters.GetReal( "Lower" ) );
+    f->SetUpper( this->m_Parameters.GetReal( "Upper" ) );
 
   } // fi
 }