]> Creatis software - clitk.git/blob - tools/clitkSplitImage.cxx
Initial revision
[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   unsigned int dim = header->GetNumberOfDimensions();
35   
36   // Check parameters
37   if (args_info.dimension_given >= dim) {
38     std::cerr << "ERROR : image has " << dim << "dimensions, split dimension should be between 0 and " << dim-1 << "." << std::endl;
39     exit(-1);
40   }
41   // Main filter
42   clitk::SplitImageGenericFilter filter;
43   filter.SetInputFilename(args_info.input_arg);
44   filter.SetOutputFilename(args_info.output_arg);
45   filter.SetSplitDimension(args_info.dimension_arg);
46   filter.SetVerbose(args_info.verbose_flag);
47   filter.Update();
48
49   // this is the end my friend  
50   return 0;
51 } // end main