]> Creatis software - FrontAlgorithms.git/blobdiff - tests/image/RandomWalker.cxx
...
[FrontAlgorithms.git] / tests / image / RandomWalker.cxx
index 59c91051b551aba4b93c2478868e38a19b26bcdf..45a15c16dff4fa8a1b015c992d580b5c12ef4173 100644 (file)
@@ -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 );
 }