]> Creatis software - clitk.git/blob - tools/clitkImageConvert.cxx
5d9eed05c628cd2b5172ccb4ce92a9b254c7b9d6
[clitk.git] / tools / clitkImageConvert.cxx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #ifndef CLITKIMAGECONVERT_CXX
19 #define CLITKIMAGECONVERT_CXX
20 /**
21    -------------------------------------------------
22    * @file   clitkImageConvert.cxx
23    * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
24    * @date   03 Jul 2006 10:28:32
25    -------------------------------------------------*/
26
27 // clitk include
28 #include "clitkImageConvert_ggo.h"
29 #include "clitkIO.h"
30 #include "clitkImageCommon.h"
31 #include "clitkImageConvertGenericFilter.h"
32
33 //-------------------------------------------------------------------=
34 int main(int argc, char * argv[]) {
35
36   // init command line
37   GGO(clitkImageConvert, args_info);
38   CLITK_INIT;
39
40   // Get list of filenames
41   std::vector<std::string> l;
42   for(unsigned int i=0; i<args_info.input_given; i++) {
43     l.push_back(args_info.input_arg[i]);
44   }
45   for(unsigned int i=0; i<args_info.inputs_num; i++) {
46     l.push_back(args_info.inputs[i]);
47   }
48   if (l.size() < 1) {
49     std::cerr << "Error, you should give at least one --input option or one image filename on the commande line." << std::endl;
50     exit(0);
51   }  
52
53   // Create filter
54   clitk::ImageConvertGenericFilter::Pointer filter = clitk::ImageConvertGenericFilter::New();
55   filter->SetInputFilenames(l);
56   filter->SetIOVerbose(args_info.verbose_flag);
57   filter->SetOutputFilename(args_info.output_arg);
58   if (args_info.type_given) filter->SetOutputPixelType(args_info.type_arg);
59
60   // Go !
61   filter->Update();  
62
63   // this is the end my friend  
64   return 0;
65 }
66 //-------------------------------------------------------------------=
67
68 #endif /* end #define CLITKIMAGECONVERT_CXX */
69