]> Creatis software - clitk.git/blob - tools/clitkSplitImage.cxx
ggo case sensitivity
[clitk.git] / tools / clitkSplitImage.cxx
1 /*------------------------------------------------------------------------=
2                                                                                 
3   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
4   l'Image). All rights reserved. See Doc/License.txt or
5   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
6                                                                                 
7   This software is distributed WITHOUT ANY WARRANTY; without even
8   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9   PURPOSE.  See the above copyright notices for more information.
10                                                                              
11   ------------------------------------------------------------------------=*/
12
13 /**
14    ------------------------------------------------=
15    * @file   clitkSplitImage.cxx
16    * @author Joël Schaerer
17    * @date   20 April 2009
18    ------------------------------------------------=*/
19
20 // clitk include
21 #include "clitkSplitImage_ggo.h"
22 #include "clitkSplitImageGenericFilter.h"
23 #include "clitkIO.h"
24
25 //--------------------------------------------------------------------
26 int main(int argc, char * argv[]) {
27
28   // Init command line
29   GGO(clitkSplitImage, args_info);
30   CLITK_INIT;
31
32   // Read image dimension
33   itk::ImageIOBase::Pointer header = clitk::readImageHeader(args_info.input_arg);
34   if (header.IsNull())
35   {
36       std::cerr << "Unable to read image file " << args_info.input_arg << std::endl;
37       std::exit(1);
38   }
39   unsigned int dim = header->GetNumberOfDimensions();
40   
41   // Check parameters
42   if (args_info.dimension_given >= dim) {
43     std::cerr << "ERROR : image has " << dim << "dimensions, split dimension should be between 0 and " << dim-1 << "." << std::endl;
44     exit(-1);
45   }
46   // Main filter
47   clitk::SplitImageGenericFilter filter;
48   filter.SetInputFilename(args_info.input_arg);
49   filter.SetOutputFilename(args_info.output_arg);
50   filter.SetSplitDimension(args_info.dimension_arg);
51   filter.SetVerbose(args_info.verbose_flag);
52   filter.Update();
53
54   // this is the end my friend  
55   return 0;
56 } // end main