+#include <itkFunctionBase.h>
#include <itkImage.h>
-#include <itkImageFileReader.h>
-#include <itkImageFileWriter.h>
-#include <itkMinimumMaximumImageCalculator.h>
-#include <itkImageRegionConstIteratorWithIndex.h>
-
-#include <fpa/Image/Dijkstra.h>
-#include <fpa/Image/Functors/GaussianWeight.h>
+#include <itkImageToImageFilter.h>
+#include <fpa/Base/Algorithm.h>
+#include <fpa/Base/SeedsInterface.h>
+#include <fpa/Base/MarksInterface.h>
// -------------------------------------------------------------------------
-static const unsigned int VDim = 2;
-typedef short TPixel;
-typedef double TScalar;
-typedef itk::Image< TPixel, VDim > TImage;
-typedef itk::Image< TScalar, VDim > TScalarImage;
-typedef itk::ImageFileReader< TImage > TReader;
-typedef itk::ImageFileWriter< TScalarImage > TWriter;
-typedef fpa::Image::Dijkstra< TImage, TScalarImage > TFilter;
-typedef itk::MinimumMaximumImageCalculator< TImage > TMinMax;
-typedef itk::ImageRegionConstIteratorWithIndex< TImage > TIterator;
-
-typedef fpa::Image::Functors::GaussianWeight< TImage, TScalar > TVertexFunc;
+namespace fpa
+{
+ namespace Base
+ {
+ namespace Functors
+ {
+ namespace RegionGrow
+ {
+ /**
+ */
+ template< class _TValue >
+ class Tautology
+ : public itk::FunctionBase< _TValue, bool >
+ {
+ public:
+ typedef Tautology Self;
+ typedef itk::FunctionBase< _TValue, bool > Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro(
+ fpa::Base::Functors::RegionGrow::Tautology,
+ itk::FunctionBase
+ );
+
+ public:
+ virtual bool Evaluate( const _TValue& input ) const override
+ {
+ return( true );
+ }
+ protected:
+ Tautology( )
+ : Superclass( )
+ {
+ }
+ virtual ~Tautology( )
+ {
+ }
+ private:
+ // Purposely not implemented
+ Tautology( const Self& other );
+ Self& operator=( const Self& other );
+ };
+
+ } // ecapseman
+
+ } // ecapseman
+
+ } // ecapseman
+
+} // ecapseman
// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
+namespace fpa
{
- // Get arguments
- if( argc < 5 )
+ namespace Base
{
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " input_image input_seeds output_image beta"
- << std::endl;
- return( 1 );
-
- } // fi
- std::string input_image_filename = argv[ 1 ];
- std::string input_seeds_filename = argv[ 2 ];
- std::string output_image_filename = argv[ 3 ];
- double beta = std::atof( argv[ 4 ] );
-
- // Read seeds
- TReader::Pointer input_seeds = TReader::New( );
- input_seeds->SetFileName( input_seeds_filename );
- try
+ /**
+ */
+ template< class _TAlgorithm >
+ class RegionGrow
+ : public _TAlgorithm
+ {
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+// -------------------------------------------------------------------------
+namespace fpa
+{
+ namespace Image
{
- input_seeds->Update( );
- }
- catch( std::exception& err )
+ /**
+ */
+ template< class _TInputImage >
+ class MarksInterface
+ {
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+// -------------------------------------------------------------------------
+namespace fpa
+{
+ namespace Image
{
- std::cerr << "Error: " << err.what( ) << std::endl;
- return( 1 );
+ /**
+ */
+ template< class _TInputImage, class _TOutputImage, class _TSeedsInterface, class _TMarksInterface >
+ class Algorithm
+ : public fpa::Base::Algorithm< itk::ImageToImageFilter< _TInputImage, _TOutputImage >, _TSeedsInterface, _TMarksInterface >
+ {
+ };
- } // yrt
- TMinMax::Pointer minmax = TMinMax::New( );
- minmax->SetImage( input_seeds->GetOutput( ) );
- minmax->Compute( );
+ } // ecapseman
- // Read image
- TReader::Pointer input_image = TReader::New( );
- input_image->SetFileName( input_image_filename );
+} // ecapseman
- // Prepare dijkstra filter
- TFilter::Pointer filter = TFilter::New( );
- filter->SetInput( input_image->GetOutput( ) );
- filter->StopAtOneFrontOff( );
-
- // Assign seeds
- /* TODO
- TIterator sIt(
- input_seeds->GetOutput( ),
- input_seeds->GetOutput( )->GetRequestedRegion( )
- );
- for( sIt.GoToBegin( ); !sIt.IsAtEnd( ); ++sIt )
- if( sIt.Get( ) > minmax->GetMinimum( ) )
- filter->AddSeed( sIt.GetIndex( ) );
- */
- TImage::IndexType seed;
- /* TODO
- seed[ 0 ] = 248;
- seed[ 1 ] = 326;
- seed[ 2 ] = 312;
- */
- seed[ 0 ] = 482;
- seed[ 1 ] = 57;
- filter->AddSeed( seed );
+// -------------------------------------------------------------------------
+namespace fpa
+{
+ namespace Image
+ {
+ /**
+ */
+ template< class _TInputImage, class _TOutputImage >
+ class RegionGrow
+ : public fpa::Base::RegionGrow< fpa::Image::Algorithm< _TInputImage, _TOutputImage, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare >, fpa::Image::MarksInterface< _TInputImage > > >
+ {
+ };
- seed[ 0 ] = 306;
- seed[ 1 ] = 439;
- filter->AddSeed( seed );
+ } // ecapseman
- TVertexFunc::Pointer vertex_func = TVertexFunc::New( );
- vertex_func->SetBeta( beta );
- filter->SetFunctor( vertex_func );
+} // ecapseman
- TWriter::Pointer writer = TWriter::New( );
- writer->SetInput( filter->GetOutput( ) );
- writer->SetFileName( output_image_filename );
+// -------------------------------------------------------------------------
+const unsigned int Dim = 2;
+typedef short TInputPixel;
+typedef unsigned char TOutputPixel;
+typedef itk::Image< TInputPixel, Dim > TInputImage;
+typedef itk::Image< TOutputPixel, Dim > TOutputImage;
- try
- {
- writer->Update( );
- }
- catch( std::exception& err )
- {
- std::cerr << "ERROR: " << err.what( ) << std::endl;
- return( 1 );
+// -------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+ TInputImage::IndexType seed;
+ seed.Fill( 0 );
+
+ typedef fpa::Base::Functors::RegionGrow::Tautology< TInputPixel > TPredicate;
+ TPredicate::Pointer tautology = TPredicate::New( );
+
+ typedef fpa::Image::RegionGrow< TInputImage, TOutputImage > TFilter;
+ TFilter::Pointer filter = TFilter::New( );
+ filter->SetInput( input_image );
+ filter->AddSeed( seed );
+ filter->SetPredicate( tautology );
+ filter->Update( );
- } // yrt
return( 0 );
}