]> Creatis software - clitk.git/blob - tools/clitkImageConvert.cxx
cosmetic for .ggo
[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://www.centreleonberard.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
37   // init command line
38   GGO(clitkImageConvert, args_info);
39   CLITK_INIT;
40
41   // Get list of filenames
42   std::vector<std::string> l;
43   unsigned int nCmdLineInputs = args_info.inputs_num;
44   std::string output;
45   if(args_info.output_given)
46     output = args_info.output_arg;
47   else if(nCmdLineInputs--)
48     output = args_info.inputs[nCmdLineInputs];
49   else {
50     std::cerr << "Error, you should give the --output option or one image filename on the commande line." << std::endl;
51     exit(0);
52   }
53
54   if(args_info.input_given) {
55     l.push_back(args_info.input_arg);
56   }
57   if(nCmdLineInputs==1) {
58     l.push_back(args_info.inputs[0]);
59   }
60   if (l.size() < 1) {
61     std::cerr << "Error, you should give the --input option or one image filename on the commande line." << std::endl;
62     exit(0);
63   }
64
65   // Create filter
66   clitk::ImageConvertGenericFilter::Pointer filter = clitk::ImageConvertGenericFilter::New();
67   filter->SetInputFilenames(l);
68   filter->SetIOVerbose(args_info.verbose_flag);
69   filter->SetOutputFilename(output);
70   filter->SetVV(args_info.vv_flag);
71   filter->SetNoNiiMeta(args_info.noniimeta_flag);
72   filter->SetCorrectNegativeSpacingFlag(args_info.correct_flag);
73   filter->EnableWriteCompression(args_info.compression_flag);
74   if (args_info.type_given) filter->SetOutputPixelType(args_info.type_arg);
75
76   // Go !
77   CLITK_TRY_CATCH_EXIT(filter->Update());
78
79   // this is the end my friend
80   return 0;
81 }
82 //-------------------------------------------------------------------=
83
84 #endif /* end #define CLITKIMAGECONVERT_CXX */