]> Creatis software - cpPlugins.git/blobdiff - appli/examples/example_LightCompensation.cxx
Light compensation algorithm added
[cpPlugins.git] / appli / examples / example_LightCompensation.cxx
diff --git a/appli/examples/example_LightCompensation.cxx b/appli/examples/example_LightCompensation.cxx
new file mode 100644 (file)
index 0000000..44062ed
--- /dev/null
@@ -0,0 +1,57 @@
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+#include <itkImage.h>
+#include <itkImageFileReader.h>
+#include <itkRGBPixel.h>
+
+#include <cpPlugins/Extensions/Algorithms/LightCompensationFilter.h>
+
+// -------------------------------------------------------------------------
+const unsigned int Dim = 2;
+typedef itk::RGBPixel< unsigned char > TPixel;
+typedef itk::Image< TPixel, Dim >      TImage;
+
+// -------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+  if( argc < 3 )
+  {
+    std::cerr
+      << "Usage: " << argv[ 0 ]
+      << " input_image output_image"
+      << std::endl;
+    return( 1 );
+
+  } // fi
+  std::string input_image_fn = argv[ 1 ];
+  std::string output_image_fn = argv[ 2 ];
+
+  // Read image
+  itk::ImageFileReader< TImage >::Pointer input_image_reader =
+    itk::ImageFileReader< TImage >::New( );
+  input_image_reader->SetFileName( input_image_fn );
+  try
+  {
+    input_image_reader->Update( );
+  }
+  catch( itk::ExceptionObject& err )
+  {
+    std::cerr << "Error caught: " << err << std::endl;
+    return( 1 );
+
+  } // yrt
+  TImage::Pointer input_image = input_image_reader->GetOutput( );
+
+  cpPlugins::Extensions::Algorithms::
+    LightCompensationFilter< TImage >::Pointer filter =
+    cpPlugins::Extensions::Algorithms::
+    LightCompensationFilter< TImage >::New( );
+  filter->SetInput( input_image );
+  filter->Update( );
+
+  return( 0 );
+}
+
+// eof - $RCSfile$