1 #include "BaseFunctions.h"
3 #include <fpa/Image/RegionGrow.h>
4 #include <fpa/Base/Functors/RegionGrow/Tautology.h>
6 // -------------------------------------------------------------------------
7 const unsigned int Dim = 2;
8 typedef unsigned char TPixel;
10 typedef itk::Image< TPixel, Dim > TImage;
11 typedef fpa::Image::RegionGrow< TImage, TImage > TFilter;
12 typedef fpa::Base::Functors::RegionGrow::Tautology< TPixel > TPredicate;
14 // -------------------------------------------------------------------------
15 int main( int argc, char* argv[] )
21 << "Usage: " << argv[ 0 ]
22 << " output_image output_marks width height visual_debug ..."
27 std::string output_image_filename = argv[ 1 ];
28 std::string output_marks_filename = argv[ 2 ];
29 int width = std::atoi( argv[ 3 ] );
30 int height = std::atoi( argv[ 4 ] );
31 bool visual_debug = ( argv[ 5 ][ 0 ] == '1' );
34 TImage::Pointer image;
35 fpa::tests::image::CreateImage( image, 0, width, height, 1.0, 1.0 );
37 // Interact with image
38 fpa::tests::image::Viewer< TFilter > viewer( image );
41 viewer.ActivateSeedWidget( );
47 TPredicate::Pointer predicate = TPredicate::New( );
50 TFilter::Pointer filter = TFilter::New( );
51 filter->SetInput( image );
52 filter->SetPredicate( predicate );
53 filter->SetInsideValue( 255 );
54 filter->SetOutsideValue( 0 );
57 for( int i = 6; i < argc; i += 2 )
61 TImage::IndexType seed;
62 seed[ 0 ] = std::atoi( argv[ i ] );
63 seed[ 1 ] = std::atoi( argv[ i + 1 ] );
64 filter->AddSeed( seed );
69 viewer.AssociateSeedsTo( filter );
71 // Prepare visual debug and update
73 viewer.ObserveFilter( filter );
78 fpa::tests::image::Write( filter->GetOutput( ), output_image_filename );
80 fpa::tests::image::Write( filter->GetMarks( ), output_marks_filename );
81 if( err1 != "" ) std::cerr << err1 << std::endl;
82 if( err2 != "" ) std::cerr << err2 << std::endl;