]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/RegionGrowWithMultipleThresholds.hxx
Some more debug... almost there
[FrontAlgorithms.git] / lib / fpa / Image / RegionGrowWithMultipleThresholds.hxx
index 0969b0cd59e082ccdf8d33c30778e75d0c171697..a5b2075b3819a45d4eff92e57b347d1a474c4f21 100644 (file)
@@ -2,43 +2,14 @@
 #define __FPA__IMAGE__REGIONGROWWITHMULTIPLETHRESHOLDS__HXX__
 
 #include <limits>
-#include <fpa/Image/Functors/RegionGrowThresholdFunction.h>
 
 // -------------------------------------------------------------------------
 template< class I >
 void fpa::Image::RegionGrowWithMultipleThresholds< I >::
 AddThreshold( const TPixel& v )
 {
-  typedef
-    fpa::Image::Functors::RegionGrowThresholdFunction< I >
-    TFunction;
-  typename TFunction::Pointer function = TFunction::New( );
-
-  if( this->GetNumberOfMembershipFunctions( ) > 0 )
-  {
-  }
-  else
-    function->SetLowerThreshold( std::numeric_limits< TPixel >::min( ) );
-  std::cout
-    << typeid( TPixel ).name( ) << " <<<----->>> "
-    << function->GetLowerThreshold( )
-    << std::endl;
-  std::exit( 1 );
-  function->SetUpperThreshold( v );
-  this->AddMembershipFunction( function );
-
-  /* TODO
-     this->m_Histogram[ v ] = 0;
-
-     TFunction* function =
-     dynamic_cast< TFunction* >( this->GetMembershipFunction( ) );
-     if( function != NULL )
-     {
-     function->SetLowerThreshold( this->m_Histogram.begin( )->first );
-
-     } // fi
-     this->Modified( );
-  */
+  this->m_Thresholds.insert( v );
+  this->Modified( );
 }
 
 // -------------------------------------------------------------------------
@@ -80,7 +51,9 @@ bool fpa::Image::RegionGrowWithMultipleThresholds< I >::
 _UpdateResult( _TNode& n )
 {
   bool ret = this->Superclass::_UpdateResult( n );
+  std::cout << "Image:UpdateResult " << ret << std::endl;
 
+  
   /* TODO
      if( ret )
      {
@@ -110,18 +83,22 @@ template< class I >
 void fpa::Image::RegionGrowWithMultipleThresholds< I >::
 _BeforeLoop( )
 {
-  std::cout << "**1" << std::endl;
   const I* img = this->GetInput( );
-  std::cout << "**2" << std::endl;
-  typename TFunctions::iterator fIt = this->m_Functions.begin( );
-  for( ; fIt != this->m_Functions.end( ); ++fIt )
+
+  this->ClearMembershipFunctions( );
+  typename TThresholds::const_iterator tIt = this->m_Thresholds.begin( );
+  typename TThresholds::const_iterator prev_tIt = tIt;
+  for( ++tIt; tIt != this->m_Thresholds.end( ); ++tIt, ++prev_tIt )
   {
-    TMembershipFunction* f =
-      dynamic_cast< TMembershipFunction* >( fIt->GetPointer( ) );
-    if( f != NULL )
-      f->SetInputImage( this->GetInput( ) );
+    typename TFunction::Pointer function = TFunction::New( );
+    function->SetInputImage( img );
+    function->SetLowerThreshold( *prev_tIt );
+    function->SetUpperThreshold( *tIt );
+    this->AddMembershipFunction( function );
+    std::cout << *prev_tIt << " " << *tIt << std::endl;
 
   } // rof
+
   this->Superclass::_BeforeLoop( );
 }