#include <vtkSeedWidget.h>
#include <vtkSmartPointer.h>
-#include <cpPlugins/Extensions/Algorithms/IterativeGaussianModelEstimator.h>
-#include <cpPlugins/Extensions/Algorithms/RGBToYPbPrFunction.h>
-
#include <fpa/Image/RegionGrow.h>
-#include <fpa/Base/Functors/TautologyFunction.h>
#include <fpa/VTK/Image2DObserver.h>
+#include <fpa/Image/Functors/GaussianModelEstimatorFunction.h>
// -------------------------------------------------------------------------
const unsigned int Dim = 2;
typedef itk::Image< TPixel, Dim > TImage;
typedef itk::ImageToVTKImageFilter< TColorImage > TVTKImage;
-// -------------------------------------------------------------------------
-template< class I, class S >
-class GaussianFunction
- : public itk::FunctionBase< typename I::PixelType, bool >
-{
-public:
- // Type-related and pointers
- typedef GaussianFunction Self;
- typedef itk::FunctionBase< typename I::PixelType, bool > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- // Superclass' types
- typedef cpPlugins::Extensions::Algorithms::IterativeGaussianModelEstimator< S, 3 > TEstimator;
- typedef cpPlugins::Extensions::Algorithms::RGBToYPbPrFunction< S > TYPbPrFunction;
-
-public:
- itkNewMacro( Self );
- itkTypeMacro( GaussianFunction, itkFunctionBase );
-
- itkGetConstMacro( ModelSupport, unsigned long );
- itkSetMacro( ModelSupport, unsigned long );
-
-public:
- virtual bool Evaluate( const typename I::PixelType& rgb ) const
- {
- /* TODO
- if( !this->m_Estimating )
- {
- this->m_Estimator->AddSample( this->m_YPbPrFunction( rgb ) );
- if( this->m_Estimator->GetNumberOfSamples( ) == this->m_ModelSupport )
- {
- this->m_Estimating = true;
- this->m_Estimator->UpdateModel( );
- std::cout << this->m_Estimator->GetMinimumProbability( ) << std::endl;
- std::cout << this->m_Estimator->GetMaximumProbability( ) << std::endl;
-
- } // fi
- return( true );
- }
- else
- {
- S p = this->m_Estimator->Probability( this->m_YPbPrFunction( rgb ) );
- return( p > this->m_Estimator->GetMinimumProbability( ) );
-
- } // fi
- */
- return( true );
- }
-
-protected:
- GaussianFunction( )
- : Superclass( ),
- m_ModelSupport( 10 )
- {
- this->m_Estimator = TEstimator::New( );
- this->m_Estimator->Clear( );
- this->m_Estimating = false;
- }
- virtual ~GaussianFunction( )
- { }
-
-private:
- // Purposely not implemented
- GaussianFunction( const Self& );
- void operator=( const Self& );
-
-protected:
- typename TEstimator::Pointer m_Estimator;
- TYPbPrFunction m_YPbPrFunction;
-
- unsigned long m_ModelSupport;
- mutable bool m_Estimating;
-};
-
// -------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
interactor->Start( );
// Prepare region grow function
- typedef GaussianFunction< TColorImage, TScalar > TFunction;
+ typedef fpa::Image::Functors::GaussianModelEstimatorFunction< TColorImage, TScalar > TFunction;
TFunction::Pointer function = TFunction::New( );
function->SetModelSupport( support );
// Go!
filter->Update( );
+ window->Render( );
+ widget->Off( );
+ interactor->Start( );
+
return( 0 );
}