]> Creatis software - clitk.git/blob - tools/clitkImageConvert.cxx
again
[clitk.git] / tools / clitkImageConvert.cxx
1 /*-------------------------------------------------------------------------
2                                                                                 
3 Program:   clitk
4 Language:  C++
5                                                                                 
6 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
7 l'Image). All rights reserved. See Doc/License.txt or
8 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
9                                                                                 
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE.  See the above copyright notices for more information.
13                                                                              
14 -------------------------------------------------------------------------*/
15
16 #ifndef CLITKIMAGECONVERT_CXX
17 #define CLITKIMAGECONVERT_CXX
18
19 /**
20    -------------------------------------------------
21    * @file   clitkImageConvert.cxx
22    * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
23    * @date   03 Jul 2006 10:28:32
24    -------------------------------------------------*/
25
26 // clitk include
27 #include "clitkImageConvert_ggo.h"
28 #include "clitkIO.h"
29 #include "clitkImageCommon.h"
30 #include "clitkImageConvertGenericFilter.h"
31
32 //-------------------------------------------------------------------=
33 int main(int argc, char * argv[]) {
34
35   // init command line
36   GGO(clitkImageConvert, args_info);
37   CLITK_INIT;
38
39   // Get list of filenames
40   std::vector<std::string> l;
41   for(unsigned int i=0; i<args_info.input_given; i++) {
42     l.push_back(args_info.input_arg[i]);
43   }
44   for(unsigned int i=0; i<args_info.inputs_num; i++) {
45     l.push_back(args_info.inputs[i]);
46   }
47   if (l.size() < 1) {
48     std::cerr << "Error, you should give at least one --input option or one image filename on the commande line." << std::endl;
49     exit(0);
50   }  
51
52   // Create filter
53   clitk::ImageConvertGenericFilter::Pointer filter = clitk::ImageConvertGenericFilter::New();
54   filter->SetInputFilenames(l);
55   filter->SetIOVerbose(args_info.verbose_flag);
56   filter->SetOutputFilename(args_info.output_arg);
57   if (args_info.type_given) filter->SetOutputPixelType(args_info.type_arg);
58
59   // Go !
60   filter->Update();  
61
62   // this is the end my friend  
63   return 0;
64 }
65 //-------------------------------------------------------------------=
66
67 #endif /* end #define CLITKIMAGECONVERT_CXX */
68