1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
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.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #ifndef CLITKIMAGEREGIONFILL_CXX
19 #define CLITKIMAGEREGIONFILL_CXX
21 ------------------------------------------------=
22 * @file clitkImageFillRegion.cxx
23 * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
25 ------------------------------------------------=*/
28 #include "clitkImageFillRegion_ggo.h"
29 #include "clitkImageFillRegionGenericFilter.h"
32 //--------------------------------------------------------------------
33 int main(int argc, char * argv[]) {
36 GGO(clitkImageFillRegion, args_info);
39 // Read image dimension
40 itk::ImageIOBase::Pointer header = clitk::readImageHeader(args_info.input_arg);
41 unsigned int dim = header->GetNumberOfDimensions();
44 clitk::ImageFillRegionGenericFilter filter;
45 filter.SetInputFilename(args_info.input_arg);
46 filter.SetOutputFilename(args_info.output_arg);
47 filter.SetFillPixelValue(args_info.value_arg);
49 if(!args_info.ellips_flag && !args_info.rect_flag)
51 std::cerr << "ERROR : No type of region specified!"<< std::endl;
55 if(args_info.ellips_flag && args_info.rect_flag)
57 std::cerr << "ERROR : Multiple types of regions specified!"<< std::endl;
61 if(args_info.rect_flag)
63 if (args_info.size_given && args_info.start_given) {
65 if (args_info.size_given != dim) {
66 std::cerr << "ERROR : image has " << dim << "dimensions, --size should have the same number of values." << std::endl;
69 if (args_info.start_given != dim) {
70 std::cerr << "ERROR : image has " << dim << "dimensions, --size should have the same number of values." << std::endl;
73 filter.SetRegion(args_info.size_arg, args_info.start_arg);
76 std::cerr << "ERROR : both size and start should be given!"<< std::endl;
81 if(args_info.ellips_flag)
84 std::vector<double> c, a;
85 if (args_info.center_given)
87 if (args_info.center_given != dim)
89 std::cerr << "ERROR : image has " << dim << "dimensions, --center should have the same number of values." << std::endl;
92 for(unsigned int i=0; i<dim; i++)
93 c.push_back(args_info.center_arg[i]);
96 if (args_info.axes_given)
98 if (args_info.axes_given != dim)
100 std::cerr << "ERROR : image has " << dim << "dimensions, --axes should have the same number of values." << std::endl;
103 for(unsigned int i=0; i<dim; i++)
104 a.push_back(args_info.axes_arg[i]);
108 for(unsigned int i=0; i<dim; i++)
111 if ((args_info.center_given))
112 filter.SetSphericRegion(a,c);
114 filter.SetSphericRegion(a);
119 // this is the end my friend
123 #endif //define CLITKIMAGEREGIONFILL