// Get list of filenames
std::vector<std::string> l;
- for(unsigned int i=0; i<args_info.input_given; i++) {
- l.push_back(args_info.input_arg[i]);
+ unsigned int nCmdLineInputs = args_info.inputs_num;
+ std::string output;
+ if(args_info.output_given)
+ output = args_info.output_arg;
+ else if(nCmdLineInputs--)
+ output = args_info.inputs[nCmdLineInputs];
+ else {
+ std::cerr << "Error, you should give the --output option or one image filename on the commande line." << std::endl;
+ exit(0);
+ }
+
+ if(args_info.input_given) {
+ l.push_back(args_info.input_arg);
}
- for(unsigned int i=0; i<args_info.inputs_num; i++) {
- l.push_back(args_info.inputs[i]);
+ if(nCmdLineInputs==1) {
+ l.push_back(args_info.inputs[0]);
}
if (l.size() < 1) {
- std::cerr << "Error, you should give at least one --input option or one image filename on the commande line." << std::endl;
+ std::cerr << "Error, you should give the --input option or one image filename on the commande line." << std::endl;
exit(0);
}
clitk::ImageConvertGenericFilter::Pointer filter = clitk::ImageConvertGenericFilter::New();
filter->SetInputFilenames(l);
filter->SetIOVerbose(args_info.verbose_flag);
- filter->SetOutputFilename(args_info.output_arg);
+ filter->SetOutputFilename(output);
filter->EnableWriteCompression(args_info.compression_flag);
if (args_info.type_given) filter->SetOutputPixelType(args_info.type_arg);
# file clitkImageConvert.ggo
package "clitkImageConvert"
version "1.0"
-purpose "Convert an image into another image.\n\tAllow to change the file format and/or the pixel type. \n\tKnown file formats 2D: jpeg png bmp tif mhd hdr vox dcm \n\tKnown file formats 3D: mhd vox hdr dcm\n\tKnown file formats 4D: mhd \n\tKnown images: 2D 3D or 4D, schar, uchar, short, ushort, int, float and double \nYou can also specify multiple inputs (i.e. \"-i a.mhd,b.mhd,c.mhd\" or \"a.mhd b.mhd ...\" without the '-i' option) having the same size and dimension to build a (n+1)D image."
+purpose "Convert an image into another image.\n\tAllow to change the file format and/or the pixel type. \n\tKnown file formats 2D: jpeg png bmp tif mhd hdr vox dcm \n\tKnown file formats 3D: mhd vox hdr dcm\n\tKnown file formats 4D: mhd \n\tKnown images: 2D 3D or 4D, schar, uchar, short, ushort, int, float and double\n\nIf the -o option is not given, the last parameter of the command line is used as output."
-option "config" - "Config file" string no
-option "input" i "Input image filename" string no multiple
-option "output" o "Output image filename" string yes
-option "type" t "Output type (float, ushort ...)" string no
-option "verbose" v "Verbose" flag off
-option "compression" c "Compress output" flag off
+option "config" - "Config file" string no
+option "input" i "Input image filename" string no
+option "output" o "Output image filename" string no
+option "type" t "Output type (float, ushort ...)" string no
+option "verbose" v "Verbose" flag off
+option "compression" c "Compress output" flag off