X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tests%2Fimage%2FRandomWalker.cxx;h=45a15c16dff4fa8a1b015c992d580b5c12ef4173;hb=6c0b77c2a8e3b821ccbe9c72c705fcd561bb90c2;hp=59c91051b551aba4b93c2478868e38a19b26bcdf;hpb=53d56cb3d8fe139843d5b2308f821cc05e7593e1;p=FrontAlgorithms.git diff --git a/tests/image/RandomWalker.cxx b/tests/image/RandomWalker.cxx index 59c9105..45a15c1 100644 --- a/tests/image/RandomWalker.cxx +++ b/tests/image/RandomWalker.cxx @@ -22,20 +22,18 @@ int main( int argc, char* argv[] ) { std::cerr << "Usage: " << argv[ 0 ] - << " input_image [labels_image] output_image output_costs" - << " alpha beta visual_debug" + << " input_image labels_image output_image output_costs" + << " alpha beta" << std::endl; return( 1 ); } // fi - int idx = ( argc == 7 )? 2: 3; std::string input_image_filename = argv[ 1 ]; - std::string labels_image_filename = ( argc == 8 )? argv[ 2 ]: ""; - std::string output_image_filename = argv[ idx ]; - std::string output_costs_filename = argv[ idx + 1 ]; - double alpha = std::atof( argv[ idx + 2 ] ); - double beta = std::atof( argv[ idx + 3 ] ); - bool visual_debug = ( argv[ idx + 4 ][ 0 ] == '1' ); + std::string labels_image_filename = argv[ 2 ]; + std::string output_image_filename = argv[ 3 ]; + std::string output_costs_filename = argv[ 4 ]; + double alpha = std::atof( argv[ 5 ] ); + double beta = std::atof( argv[ 6 ] ); // Read image TInputImage::Pointer image; @@ -49,25 +47,11 @@ int main( int argc, char* argv[] ) // Read label TLabelImage::Pointer labels; - if( labels_image_filename != "" ) + std::string err1 = fpa::tests::image::Read( labels, labels_image_filename ); + if( err1 != "" ) { - std::string err1 = fpa::tests::image::Read( labels, labels_image_filename ); - if( err1 != "" ) - { - std::cerr << "Error caught: " << err1 << std::endl; - return( 1 ); - - } // fi - - } // fi - - // Interact with image - fpa::tests::image::Viewer< TFilter > viewer( image ); - if( visual_debug ) - { - if( labels.IsNull( ) ) - viewer.ActivateBrushWidget( ); - viewer.Show( ); + std::cerr << "Error caught: " << err1 << std::endl; + return( 1 ); } // fi @@ -80,14 +64,9 @@ int main( int argc, char* argv[] ) TFilter::Pointer filter = TFilter::New( ); filter->SetInput( image ); filter->SetWeightFunction( weight ); - if( labels.IsNull( ) ) - viewer.AssociateLabelsTo( filter ); - else - filter->SetLabels( labels ); + filter->SetLabels( labels ); - // Prepare visual debug and update - if( visual_debug ) - viewer.ObserveFilter( filter ); + // Execute filter try { filter->Update( ); @@ -100,12 +79,12 @@ int main( int argc, char* argv[] ) } // yrt // Save results - std::string err1 = - fpa::tests::image::Write( filter->GetMarks( ), output_image_filename ); std::string err2 = + fpa::tests::image::Write( filter->GetMarks( ), output_image_filename ); + std::string err3 = fpa::tests::image::Write( filter->GetOutput( ), output_costs_filename ); - if( err1 != "" ) std::cerr << "Error caught: " << err1 << std::endl; if( err2 != "" ) std::cerr << "Error caught: " << err2 << std::endl; + if( err3 != "" ) std::cerr << "Error caught: " << err3 << std::endl; return( 0 ); }