]> Creatis software - clitk.git/blob - tools/clitkDicomRTStruct2BinaryImage.cxx
changes in license header
[clitk.git] / tools / clitkDicomRTStruct2BinaryImage.cxx
1 /*=========================================================================
2   Program:         vv http://www.creatis.insa-lyon.fr/rio/vv
3   Main authors :   XX XX XX
4
5   Authors belongs to: 
6   - University of LYON           http://www.universite-lyon.fr/
7   - Léon Bérard cancer center    http://www.centreleonberard.fr
8   - CREATIS CNRS laboratory      http://www.creatis.insa-lyon.fr
9
10   This software is distributed WITHOUT ANY WARRANTY; without even
11   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12   PURPOSE.  See the copyright notices for more information.
13
14   It is distributed under dual licence
15   - BSD       http://www.opensource.org/licenses/bsd-license.php
16   - CeCILL-B  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17
18   =========================================================================*/
19
20 #include "clitkDicomRT_ROI_ConvertToImageFilter.h"
21 #include "clitkDicomRT_StructureSet.h"
22 #include "clitkDicomRTStruct2BinaryImage_ggo.h"
23
24 //--------------------------------------------------------------------
25 int main(int argc, char * argv[]) {
26
27   // Init command line
28   GGO(clitkDicomRTStruct2BinaryImage, args_info);
29
30   // Read and display information
31   clitk::DicomRT_StructureSet::Pointer s = clitk::DicomRT_StructureSet::New();
32   s->Read(args_info.input_arg);
33   // s->Print(std::cout);
34   
35   // New filter to convert to binary image
36   clitk::DicomRT_ROI_ConvertToImageFilter filter;
37   filter.SetCropMaskEnabled(args_info.crop_flag);
38   filter.SetImageFilename(args_info.image_arg);  // Used to get spacing + origin
39   if (args_info.roi_arg != -1) {
40     filter.SetROI(s->GetROI(args_info.roi_arg)); 
41     filter.SetOutputImageFilename(args_info.output_arg);
42   filter.Update();  
43   }
44   else {
45     for(unsigned int i=0; i<s->GetListOfROI().size(); i++) {
46       clitk::DicomRT_ROI_ConvertToImageFilter filter;
47       filter.SetCropMaskEnabled(args_info.crop_flag);
48       filter.SetImageFilename(args_info.image_arg);  // Used to get spacing + origin
49       std::string name = s->GetListOfROI()[i]->GetName();
50       int num = s->GetListOfROI()[i]->GetROINumber();
51       filter.SetROI(s->GetListOfROI()[i]); 
52       name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
53       std::string n = std::string(args_info.output_arg).append
54         (clitk::toString(num)).append
55         ("_").append
56         (name).append
57         (".mhd");
58       if (args_info.verbose_flag) {
59         std::cout << i << " " << s->GetListOfROI()[i]->GetName() << " num=" << num << " : " << n << std::endl;
60       }
61       filter.SetOutputImageFilename(n);
62       filter.Update();  
63     }
64   }
65
66   // This is the end my friend 
67   return 0;
68 }