6 #include <itkImageFileReader.h>
7 #include <itkRGBPixel.h>
9 #include <cpPlugins/Extensions/Algorithms/ParallelImageMean.h>
11 // -------------------------------------------------------------------------
12 const unsigned int Dim = 2;
13 typedef itk::RGBPixel< unsigned char > TPixel;
14 typedef itk::Image< TPixel, Dim > TImage;
16 // -------------------------------------------------------------------------
17 int main( int argc, char* argv[] )
21 std::cerr << "Usage: " << argv[ 0 ] << " image" << std::endl;
25 std::string image_fn = argv[ 1 ];
28 itk::ImageFileReader< TImage >::Pointer image_reader =
29 itk::ImageFileReader< TImage >::New( );
30 image_reader->SetFileName( image_fn );
33 image_reader->Update( );
35 catch( itk::ExceptionObject& err )
37 std::cerr << "Error caught: " << err << std::endl;
41 TImage::Pointer image = image_reader->GetOutput( );
44 cpPlugins::Extensions::Algorithms::ParallelImageMean< TImage >::Pointer mean =
45 cpPlugins::Extensions::Algorithms::ParallelImageMean< TImage >::New( );
46 mean->Execute( image, image->GetRequestedRegion( ) );
47 std::cout << "Mean: " << mean->GetMean( ) << std::endl;