]> Creatis software - cpPlugins.git/blob - appli/examples/example_LightCompensation.cxx
Light compensation algorithm added
[cpPlugins.git] / appli / examples / example_LightCompensation.cxx
1 #include <cstdlib>
2 #include <iostream>
3 #include <string>
4
5 #include <itkImage.h>
6 #include <itkImageFileReader.h>
7 #include <itkRGBPixel.h>
8
9 #include <cpPlugins/Extensions/Algorithms/LightCompensationFilter.h>
10
11 // -------------------------------------------------------------------------
12 const unsigned int Dim = 2;
13 typedef itk::RGBPixel< unsigned char > TPixel;
14 typedef itk::Image< TPixel, Dim >      TImage;
15
16 // -------------------------------------------------------------------------
17 int main( int argc, char* argv[] )
18 {
19   if( argc < 3 )
20   {
21     std::cerr
22       << "Usage: " << argv[ 0 ]
23       << " input_image output_image"
24       << std::endl;
25     return( 1 );
26
27   } // fi
28   std::string input_image_fn = argv[ 1 ];
29   std::string output_image_fn = argv[ 2 ];
30
31   // Read image
32   itk::ImageFileReader< TImage >::Pointer input_image_reader =
33     itk::ImageFileReader< TImage >::New( );
34   input_image_reader->SetFileName( input_image_fn );
35   try
36   {
37     input_image_reader->Update( );
38   }
39   catch( itk::ExceptionObject& err )
40   {
41     std::cerr << "Error caught: " << err << std::endl;
42     return( 1 );
43
44   } // yrt
45   TImage::Pointer input_image = input_image_reader->GetOutput( );
46
47   cpPlugins::Extensions::Algorithms::
48     LightCompensationFilter< TImage >::Pointer filter =
49     cpPlugins::Extensions::Algorithms::
50     LightCompensationFilter< TImage >::New( );
51   filter->SetInput( input_image );
52   filter->Update( );
53
54   return( 0 );
55 }
56
57 // eof - $RCSfile$