#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( );
}
// -------------------------------------------------------------------------
_UpdateResult( _TNode& n )
{
bool ret = this->Superclass::_UpdateResult( n );
+ std::cout << "Image:UpdateResult " << ret << std::endl;
+
/* TODO
if( ret )
{
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( );
}