]> Creatis software - FrontAlgorithms.git/blobdiff - libs/fpa/Image/MoriFilterHelper.hxx
...
[FrontAlgorithms.git] / libs / fpa / Image / MoriFilterHelper.hxx
index 4ddb234232a1019a0396231e703fedfe94fcfeea..fb6826ad5e16de2ccaa08c1e5bf08236a72d8470 100644 (file)
@@ -32,11 +32,10 @@ _ContinueGenerateData( )
 {
   TBinThresholdFunction* functor =
     dynamic_cast< TBinThresholdFunction* >( this->GetGrowFunction( ) );
-  TPixel u = functor->GetUpper( );
 
   // Update flooding data
+  TPixel u = functor->GetUpper( );
   this->m_Curve.push_back( TCurveData( u, this->m_ActualCount ) );
-  std::cout << u << " " << this->m_ActualCount << std::endl;
 
   // Update thresholds
   if( u < this->m_Upper )
@@ -45,9 +44,30 @@ _ContinueGenerateData( )
     if( u > this->m_Upper )
       u = this->m_Upper;
     functor->SetUpper( u );
-    this->m_Queue = this->m_NextQueue;
+
+    while( this->m_Queue.size( ) > 0 )
+      this->m_Queue.pop( );
+    // TODO: std::cout << "-----> " << this->m_NextQueue.size( ) << " " << u << std::endl;
     while( this->m_NextQueue.size( ) > 0 )
+    {
+      this->m_Queue.push( this->m_NextQueue.front( ) );
+      // TODO: std::cout << "\t" << this->m_NextQueue.front( ).Vertex << std::endl;
       this->m_NextQueue.pop( );
+
+    } // elihw
+
+    /* TODO: ensure pixels belong to new threshold?
+       while( this->m_Queue.size( ) > 0 )
+       this->m_Queue.pop( );
+       while( this->m_NextQueue.size( ) > 0 )
+       {
+       _TQueueNode n = this->m_NextQueue.front( );
+       this->m_NextQueue.pop( );
+
+       if( ??? )
+       this->m_Queue.push( n );
+       }
+    */
     return( true );
   }
   else
@@ -122,22 +142,38 @@ template< class _TInputImage, class _TOutputImage >
 bool fpa::Image::MoriFilterHelper< _TInputImage, _TOutputImage >::
 _UpdateValue( _TQueueNode& v, const _TQueueNode& p )
 {
-  typedef typename _TOutputImage::PixelType _TOut;
-
-  bool ret = this->Superclass::_UpdateValue( v, p );
-  v.Result = _TOut( this->m_Curve.size( ) + 1 );
-  if( !ret )
-    this->m_NextQueue.push( v );
-  return( ret );
+  return( this->Superclass::_UpdateValue( v, p ) );
+  /* TODO
+     typedef typename _TOutputImage::PixelType _TOut;
+
+     bool ret = this->Superclass::_UpdateValue( v, p );
+     v.Result = _TOut( this->m_Curve.size( ) + 1 );
+     if( !ret )
+     this->m_NextQueue.push( v );
+     return( ret );
+  */
 }
 
 // -------------------------------------------------------------------------
 template< class _TInputImage, class _TOutputImage >
-void fpa::Image::MoriFilterHelper< _TInputImage, _TOutputImage >::
-_UpdateResult( const _TQueueNode& n )
+bool fpa::Image::MoriFilterHelper< _TInputImage, _TOutputImage >::
+_UpdateResult( _TQueueNode& n )
 {
-  this->Superclass::_UpdateResult( n );
-  this->m_ActualCount += 1;
+  typedef typename _TOutputImage::PixelType _TOut;
+
+  n.Result = _TOut( this->m_Curve.size( ) + 1 );
+  if( this->Superclass::_UpdateResult( n ) )
+  {
+    this->m_ActualCount += 1;
+    std::cout << this->m_ActualCount << std::endl;
+    return( true );
+  }
+  else
+  {
+    this->m_NextQueue.push( n );
+    return( false );
+
+  } // fi
 }
 
 #endif // __fpa__Image__MoriFilterHelper__hxx__