]> Creatis software - FrontAlgorithms.git/blobdiff - tests/image/MoriSegmentation.cxx
...
[FrontAlgorithms.git] / tests / image / MoriSegmentation.cxx
index e02b359edc6231e1b6cfccc91671add0c3940988..d1b26f52bb6f2600fa073042426cc1bb53f7a224 100644 (file)
@@ -3,22 +3,24 @@
 #include <fpa/Image/Mori.h>
 
 // -------------------------------------------------------------------------
-const unsigned int Dim = 2;
-typedef unsigned char TPixel;
+const unsigned int Dim = 3;
+typedef short          TPixel;
+typedef unsigned short TLabel;
 
-typedef itk::Image< TPixel, Dim >          TImage;
-typedef fpa::Image::Mori< TImage, TImage > TFilter;
+typedef itk::Image< TPixel, Dim > TInputImage;
+typedef itk::Image< TLabel, Dim > TLabelImage;
+typedef fpa::Image::Mori< TInputImage, TLabelImage > TFilter;
 
 // -------------------------------------------------------------------------
 int main( int argc, char* argv[] )
 {
   // Get arguments
-  if( argc < 9 )
+  if( argc < 8 + Dim )
   {
     std::cerr
       << "Usage: " << argv[ 0 ]
       << " input_image output_image output_levels"
-      << " init_threshold end_threshold number_of_threshold seed_x seed_y"
+      << " init_threshold end_threshold delta [index/point] seed"
       << std::endl;
     return( 1 );
 
@@ -26,15 +28,24 @@ int main( int argc, char* argv[] )
   std::string input_image_filename = argv[ 1 ];
   std::string output_image_filename = argv[ 2 ];
   std::string output_levels_filename = argv[ 3 ];
-  unsigned char init_threshold = std::atoi( argv[ 4 ] );
-  unsigned char end_threshold = std::atoi( argv[ 5 ] );
-  unsigned char number_of_thresholds = std::atoi( argv[ 6 ] );
-  TImage::IndexType seed;
-  seed[ 0 ] = std::atoi( argv[ 7 ] );
-  seed[ 1 ] = std::atoi( argv[ 8 ] );
+  TPixel init_threshold = std::atoi( argv[ 4 ] );
+  TPixel end_threshold = std::atoi( argv[ 5 ] );
+  TPixel delta = std::atoi( argv[ 6 ] );
+  std::string seed_type = argv[ 7 ];
+
+  TInputImage::IndexType iseed;
+  TInputImage::PointType pseed;
+  for( unsigned int i = 0; i < Dim; ++i )
+  {
+    if( seed_type == "index" )
+      iseed[ i ] = std::atoi( argv[ 8 + i ] );
+    else
+      pseed[ i ] = std::atof( argv[ 8 + i ] );
+
+  } // rof
 
   // Create image
-  TImage::Pointer input_image;
+  TInputImage::Pointer input_image;
   std::string err0 =
     fpa::tests::image::Read( input_image, input_image_filename );
   if( err0 != "" ) std::cerr << err0 << std::endl;
@@ -42,8 +53,11 @@ int main( int argc, char* argv[] )
   // Prepare filter
   TFilter::Pointer filter = TFilter::New( );
   filter->SetInput( input_image );
-  filter->SetSeed( seed );
-  filter->SetThresholds( init_threshold, end_threshold, number_of_thresholds );
+  if( seed_type == "index" )
+    filter->SetSeed( iseed );
+  else
+    filter->SetSeed( pseed );
+  filter->SetThresholds( init_threshold, end_threshold, delta );
   filter->SetInsideValue( 255 );
   filter->SetOutsideValue( 0 );