1 /*------------------------------------------------------------------------=
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.
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.
11 ------------------------------------------------------------------------=*/
13 #ifndef CLITKIMAGEREGIONFILL_CXX
14 #define CLITKIMAGEREGIONFILL_CXX
17 ------------------------------------------------=
18 * @file clitkImageFillRegion.cxx
19 * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
21 ------------------------------------------------=*/
24 #include "clitkImageFillRegion_ggo.h"
25 #include "clitkImageFillRegionGenericFilter.h"
28 //--------------------------------------------------------------------
29 int main(int argc, char * argv[]) {
32 GGO(clitkImageFillRegion, args_info);
35 // Read image dimension
36 itk::ImageIOBase::Pointer header = clitk::readImageHeader(args_info.input_arg);
37 unsigned int dim = header->GetNumberOfDimensions();
40 clitk::ImageFillRegionGenericFilter filter;
41 filter.SetInputFilename(args_info.input_arg);
42 filter.SetOutputFilename(args_info.output_arg);
43 filter.SetFillPixelValue(args_info.value_arg);
45 if(!args_info.ellips_flag && !args_info.rect_flag)
47 std::cerr << "ERROR : No type of region specified!"<< std::endl;
51 if(args_info.ellips_flag && args_info.rect_flag)
53 std::cerr << "ERROR : Multiple types of regions specified!"<< std::endl;
57 if(args_info.rect_flag)
59 if (args_info.size_given && args_info.start_given) {
61 if (args_info.size_given != dim) {
62 std::cerr << "ERROR : image has " << dim << "dimensions, --size should have the same number of values." << std::endl;
65 if (args_info.start_given != dim) {
66 std::cerr << "ERROR : image has " << dim << "dimensions, --size should have the same number of values." << std::endl;
69 filter.SetRegion(args_info.size_arg, args_info.start_arg);
72 std::cerr << "ERROR : both size and start should be given!"<< std::endl;
77 if(args_info.ellips_flag)
80 std::vector<double> c, a;
81 if (args_info.center_given)
83 if (args_info.center_given != dim)
85 std::cerr << "ERROR : image has " << dim << "dimensions, --center should have the same number of values." << std::endl;
88 for(unsigned int i=0; i<dim; i++)
89 c.push_back(args_info.center_arg[i]);
92 if (args_info.axes_given)
94 if (args_info.axes_given != dim)
96 std::cerr << "ERROR : image has " << dim << "dimensions, --axes should have the same number of values." << std::endl;
99 for(unsigned int i=0; i<dim; i++)
100 a.push_back(args_info.axes_arg[i]);
104 for(unsigned int i=0; i<dim; i++)
107 if ((args_info.center_given))
108 filter.SetSphericRegion(a,c);
110 filter.SetSphericRegion(a);
115 // this is the end my friend
119 #endif //define CLITKIMAGEREGIONFILL