6 #include <cpPlugins/Interface/Interface.h>
7 #include <cpPlugins/Interface/ProcessObject.h>
9 int main( int argc, char* argv[] )
14 << "Usage: " << argv[ 0 ]
17 << " dimensions pixel_type is_color input_image_files" << std::endl;
21 std::string plugins_file = argv[ 1 ];
22 std::string output_image_file = argv[ 2 ];
23 std::string dimensions = argv[ 3 ];
24 std::string pixel_type = argv[ 4 ];
25 bool is_color = ( std::atoi( argv[ 5 ] ) == 1 );
27 std::stringstream input_image_files;
28 for( int i = 6; i < argc; ++i )
29 input_image_files << argv[ i ] << ";";
32 typedef cpPlugins::Interface::Interface TInterface;
33 typedef TInterface::TClasses TClasses;
36 plugins.Load( plugins_file );
39 typedef cpPlugins::Interface::ProcessObject TProcessObject;
40 typedef TProcessObject::TParameters TParameters;
41 cpPlugins::Interface::ProcessObject::Pointer reader;
42 cpPlugins::Interface::ProcessObject::Pointer writer;
45 plugins.CreateProcessObject( "cpPlugins::Plugins::ImageSeriesReader" );
46 if( reader.IsNull( ) )
48 std::cerr << "No suitable reader found in plugins." << std::endl;
52 writer = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageWriter" );
53 if( writer.IsNull( ) )
55 std::cerr << "No suitable writer found in plugins." << std::endl;
61 TParameters reader_params = reader->GetDefaultParameters( );
62 reader_params[ "FileNames" ].second = input_image_files.str( );
63 reader_params[ "PixelType" ].second = pixel_type;
64 reader_params[ "ImageDimension" ].second = dimensions;
65 reader_params[ "IsColorImage" ].second = ( is_color )? "1": "0";
66 reader->SetParameters( reader_params );
69 TParameters writer_params = writer->GetDefaultParameters( );
70 writer_params[ "FileName" ].second = output_image_file;
71 writer->SetParameters( writer_params );
74 writer->SetInput( 0, reader->GetOutput( 0 ) );
76 std::string msg = writer->Update( );
79 std::cerr << "ERROR: " << msg << std::endl;