1 #include "BaseFunctions.h"
3 #include <fpa/Image/RegionGrow.h>
4 #include <fpa/Base/Functors/RegionGrow/BinaryThreshold.h>
6 // -------------------------------------------------------------------------
7 const unsigned int Dim = 3;
8 typedef short TInputPixel;
9 typedef unsigned char TOutputPixel;
11 typedef itk::Image< TInputPixel, Dim > TInputImage;
12 typedef itk::Image< TOutputPixel, Dim > TOutputImage;
13 typedef fpa::Image::RegionGrow< TInputImage, TOutputImage > TFilter;
14 typedef fpa::Base::Functors::RegionGrow::BinaryThreshold< TInputPixel > TPredicate;
16 // -------------------------------------------------------------------------
17 int main( int argc, char* argv[] )
23 << "Usage: " << argv[ 0 ]
24 << " input_image output_image output_marks"
25 << " lower upper strict [index/point] ..."
30 std::string input_image_filename = argv[ 1 ];
31 std::string output_image_filename = argv[ 2 ];
32 std::string output_marks_filename = argv[ 3 ];
33 TInputPixel lower = TInputPixel( std::atof( argv[ 4 ] ) );
34 TInputPixel upper = TInputPixel( std::atof( argv[ 5 ] ) );
35 bool strict = ( argv[ 6 ][ 0 ] == '1' );
36 std::string seeds_type = argv[ 7 ];
39 TInputImage::Pointer input_image;
41 fpa::tests::image::Read( input_image, input_image_filename );
42 if( err0 != "" ) std::cerr << err0 << std::endl;
45 TPredicate::Pointer predicate = TPredicate::New( );
46 predicate->SetLower( lower );
47 predicate->SetUpper( upper );
48 predicate->SetStrict( strict );
51 TFilter::Pointer filter = TFilter::New( );
52 filter->SetInput( input_image );
53 filter->SetPredicate( predicate );
54 filter->SetInsideValue( 255 );
55 filter->SetOutsideValue( 0 );
58 for( int i = 8; i < argc; i += Dim )
60 if( seeds_type == "index" )
62 TInputImage::IndexType seed;
63 for( unsigned int d = 0; d < Dim; ++d )
64 seed[ d ] = std::atoi( argv[ i + d ] );
65 filter->AddSeed( seed );
69 TInputImage::PointType seed;
70 for( unsigned int d = 0; d < Dim; ++d )
71 seed[ d ] = std::atof( argv[ i + d ] );
72 filter->AddSeed( seed );
82 fpa::tests::image::Write( filter->GetOutput( ), output_image_filename );
84 fpa::tests::image::Write( filter->GetMarks( ), output_marks_filename );
85 if( err1 != "" ) std::cerr << err1 << std::endl;
86 if( err2 != "" ) std::cerr << err2 << std::endl;