#include "BaseFunctions.h" #include #include #include // ------------------------------------------------------------------------- const unsigned int Dim = 3; typedef short TInputPixel; typedef unsigned char TOutputPixel; typedef itk::Image< TInputPixel, Dim > TInputImage; typedef itk::Image< TOutputPixel, Dim > TOutputImage; typedef fpa::Image::RegionGrow< TInputImage, TOutputImage > TFilter; typedef fpa::Base::Functors::RegionGrow::BinaryThreshold< TInputPixel > TPredicate; // ------------------------------------------------------------------------- int main( int argc, char* argv[] ) { // Get arguments if( argc < 8 + Dim ) { std::cerr << "Usage: " << argv[ 0 ] << " input_image output_image output_marks" << " lower upper strict [index/point] ..." << std::endl; return( 1 ); } // fi std::string input_image_filename = argv[ 1 ]; std::string output_image_filename = argv[ 2 ]; std::string output_marks_filename = argv[ 3 ]; TInputPixel lower = TInputPixel( std::atof( argv[ 4 ] ) ); TInputPixel upper = TInputPixel( std::atof( argv[ 5 ] ) ); bool strict = ( argv[ 6 ][ 0 ] == '1' ); std::string seeds_type = argv[ 7 ]; // Create image TInputImage::Pointer input_image; std::string err0 = fpa::tests::image::Read( input_image, input_image_filename ); if( err0 != "" ) std::cerr << err0 << std::endl; // Prepare predicate TPredicate::Pointer predicate = TPredicate::New( ); predicate->SetLower( lower ); predicate->SetUpper( upper ); predicate->SetStrict( strict ); // Prepare filter TFilter::Pointer filter = TFilter::New( ); filter->SetInput( input_image ); filter->SetPredicate( predicate ); filter->SetInsideValue( 255 ); filter->SetOutsideValue( 0 ); // Get all seeds for( int i = 8; i < argc; i += Dim ) { if( seeds_type == "index" ) { TInputImage::IndexType seed; for( unsigned int d = 0; d < Dim; ++d ) seed[ d ] = std::atoi( argv[ i + d ] ); filter->AddSeed( seed ); } else { TInputImage::PointType seed; for( unsigned int d = 0; d < Dim; ++d ) seed[ d ] = std::atof( argv[ i + d ] ); filter->AddSeed( seed ); } // fi } // rof // Execute filter filter->Update( ); // Save results std::string err1 = fpa::tests::image::Write( filter->GetOutput( ), output_image_filename ); std::string err2 = fpa::tests::image::Write( filter->GetMarks( ), output_marks_filename ); if( err1 != "" ) std::cerr << err1 << std::endl; if( err2 != "" ) std::cerr << err2 << std::endl; return( 0 ); } // eof - $RCSfile$