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