5 #include <cpPlugins/Interface/Interface.h>
6 #include <cpPlugins/Interface/DataObject.h>
7 #include <cpPlugins/Interface/ProcessObject.h>
9 // -------------------------------------------------------------------------
10 typedef cpPlugins::Interface::Interface TInterface;
11 typedef cpPlugins::Interface::DataObject TDataObject;
12 typedef TInterface::TClasses TClasses;
13 typedef cpPlugins::Interface::ProcessObject TProcessObject;
14 typedef TProcessObject::TParameters TParameters;
16 // -------------------------------------------------------------------------
18 TInterface& plugins, const std::string& fname, TDataObject* image
21 cpPlugins::Interface::ProcessObject* writer;
23 dynamic_cast< TProcessObject* >(
24 plugins.CreateObject( "cpPlugins::Plugins::ImageWriter" )
28 std::cerr << "No suitable writer found in plugins." << std::endl;
33 TParameters writer_params = writer->GetDefaultParameters( );
34 writer_params[ "FileName" ].second = fname;
35 writer->SetParameters( writer_params );
37 writer->SetInput( 0, image );
38 std::string msg = writer->Update( );
40 std::cerr << "ERROR: " << msg << std::endl;
44 // -------------------------------------------------------------------------
45 int main( int argc, char* argv[] )
50 << "Usage: " << argv[ 0 ]
53 << " output_hue_image output_saturation_image output_value_image"
54 << " dimensions pixel_type" << std::endl;
58 std::string plugins_file = argv[ 1 ];
59 std::string input_image_file = argv[ 2 ];
60 std::string output_hue_image_file = argv[ 3 ];
61 std::string output_saturation_image_file = argv[ 4 ];
62 std::string output_value_image_file = argv[ 5 ];
63 std::string dimensions = argv[ 6 ];
64 std::string pixel_type = argv[ 7 ];
69 plugins.Load( plugins_file );
72 cpPlugins::Interface::ProcessObject* reader;
73 cpPlugins::Interface::ProcessObject* filter;
76 dynamic_cast< TProcessObject* >(
77 plugins.CreateObject( "cpPlugins::Plugins::ImageReader" )
81 std::cerr << "No suitable reader found in plugins." << std::endl;
86 dynamic_cast< TProcessObject* >(
87 plugins.CreateObject( "cpPlugins::Plugins::RGBImageToHSVChannelsFilter" )
91 std::cerr << "No suitable filter found in plugins." << std::endl;
97 TParameters reader_params = reader->GetDefaultParameters( );
98 reader_params[ "FileName" ].second = input_image_file;
99 reader_params[ "PixelType" ].second = pixel_type;
100 reader_params[ "ImageDimension" ].second = dimensions;
101 reader_params[ "IsColorImage" ].second = "1";
102 reader->SetParameters( reader_params );
105 filter->SetInput( 0, reader->GetOutput( 0 ) );
108 SaveImage( plugins, output_hue_image_file, filter->GetOutput( 0 ) );
109 SaveImage( plugins, output_saturation_image_file, filter->GetOutput( 1 ) );
110 SaveImage( plugins, output_value_image_file, filter->GetOutput( 2 ) );