]> Creatis software - FrontAlgorithms.git/blobdiff - appli/CTBronchi/AndSegmentations.cxx
Merge branch 'sandbox' of ssh://git.creatis.insa-lyon.fr/FrontAlgorithms into sandbox
[FrontAlgorithms.git] / appli / CTBronchi / AndSegmentations.cxx
diff --git a/appli/CTBronchi/AndSegmentations.cxx b/appli/CTBronchi/AndSegmentations.cxx
new file mode 100644 (file)
index 0000000..4bd76a7
--- /dev/null
@@ -0,0 +1,81 @@
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+
+#include <string>
+#include <tclap/CmdLine.h>
+#include <itkImage.h>
+#include <itkAndImageFilter.h>
+#include "Functions.h"
+
+// -------------------------------------------------------------------------
+const unsigned int Dim = 3;
+typedef unsigned char             TPixel;
+typedef itk::Image< TPixel, Dim > TImage;
+
+// -------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+  typedef TCLAP::ValueArg< std::string > _TStringArg;
+
+  // Parse input line
+  _TStringArg in1( "i", "input1", "Input image 1", true, "", "file" );
+  _TStringArg in2( "j", "input2", "Input image 2", true, "", "file" );
+  _TStringArg out( "o", "output", "Output image", true, "", "file" );
+  try
+  {
+    TCLAP::CmdLine cmd( "FastRandomWalker", ' ', "1.0.0" );
+    cmd.add( out );
+    cmd.add( in2 );
+    cmd.add( in1 );
+    cmd.parse( argc, argv );
+  }
+  catch( TCLAP::ArgException& err )
+  {
+    std::cerr
+      << "===============================" << std::endl
+      << "Error caught: " << std::endl
+      << err.error( ) << " " << err.argId( ) << std::endl
+      << "===============================" << std::endl
+      << std::endl;
+    return( 1 );
+
+  } // yrt
+
+  try
+  {
+    // Read input image 1
+    TImage::Pointer input_image1;
+    CTBronchi::ReadImage( input_image1, in1.getValue( ) );
+
+    // Read input image 2
+    TImage::Pointer input_image2;
+    CTBronchi::ReadImage( input_image2, in2.getValue( ) );
+
+    // And images
+    typedef itk::AndImageFilter< TImage, TImage, TImage > TFilter;
+    TFilter::Pointer filter = TFilter::New( );
+    filter->SetInput1( input_image1 );
+    filter->SetInput2( input_image2 );
+    double t = CTBronchi::MeasureTime( filter );
+    std::cout << "And filter executed in " << t << " s" << std::endl;
+
+    // Write result
+    CTBronchi::WriteImage( filter->GetOutput( ), out.getValue( ) );
+  }
+  catch( std::exception& err )
+  {
+    std::cerr
+      << "===============================" << std::endl
+      << "Error caught: " << std::endl
+      << err.what( ) << std::endl
+      << "===============================" << std::endl
+      << std::endl;
+    return( 1 );
+
+  } // yrt
+  return( 0 );
+}
+
+// eof - $RCSfile$