]> Creatis software - clitk.git/blob - tools/clitkRelativePositionAnalyzerGenericFilter.txx
Second version of clitkRelativePositionAnalyzer
[clitk.git] / tools / clitkRelativePositionAnalyzerGenericFilter.txx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
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.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17   ===========================================================================**/
18
19 //--------------------------------------------------------------------
20 template<class ArgsInfoType>
21 clitk::RelativePositionAnalyzerGenericFilter<ArgsInfoType>::
22 RelativePositionAnalyzerGenericFilter():
23   ImageToImageGenericFilter<Self>("RelativePositionAnalyzer")
24 {
25   // Default values
26   cmdline_parser_clitkRelativePositionAnalyzer_init(&mArgsInfo);
27   InitializeImageType<3>();
28 }
29 //--------------------------------------------------------------------
30
31
32 //--------------------------------------------------------------------
33 template<class ArgsInfoType>
34 template<unsigned int Dim>
35 void clitk::RelativePositionAnalyzerGenericFilter<ArgsInfoType>::
36 InitializeImageType() 
37 {  
38   ADD_IMAGE_TYPE(Dim, uchar);
39 }
40 //--------------------------------------------------------------------
41   
42
43 //--------------------------------------------------------------------
44 template<class ArgsInfoType>
45 void clitk::RelativePositionAnalyzerGenericFilter<ArgsInfoType>::
46 SetArgsInfo(const ArgsInfoType & a) 
47 {
48   mArgsInfo=a;
49   SetIOVerbose(mArgsInfo.verbose_flag);
50   if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
51   if (mArgsInfo.support_given) AddInputFilename(mArgsInfo.support_arg);
52   if (mArgsInfo.object_given) AddInputFilename(mArgsInfo.object_arg);
53   if (mArgsInfo.target_given) AddInputFilename(mArgsInfo.target_arg);
54   if (mArgsInfo.output_given) AddOutputFilename(mArgsInfo.output_arg);
55 }
56 //--------------------------------------------------------------------
57
58
59 //--------------------------------------------------------------------
60 // Update with the number of dimensions and the pixeltype
61 //--------------------------------------------------------------------
62 template<class ArgsInfoType>
63 template<class FilterType>
64 void clitk::RelativePositionAnalyzerGenericFilter<ArgsInfoType>::
65 SetOptionsFromArgsInfoToFilter(FilterType * f) 
66 {
67   f->SetAFDBFilename(mArgsInfo.afdb_arg);
68   f->SetNumberOfBins(mArgsInfo.bins_arg);
69   f->SetNumberOfAngles(mArgsInfo.nb_arg);
70   f->SetAreaLossTolerance(mArgsInfo.tol_arg);
71 }
72
73 //--------------------------------------------------------------------
74 // Update with the number of dimensions and the pixeltype
75 //--------------------------------------------------------------------
76 template<class ArgsInfoType>
77 template<class ImageType>
78 void clitk::RelativePositionAnalyzerGenericFilter<ArgsInfoType>::
79 UpdateWithInputImageType() 
80
81   // Create filter
82   typedef clitk::RelativePositionAnalyzerFilter<ImageType> FilterType;
83   typename FilterType::Pointer filter = FilterType::New();
84   
85   // Reading input
86   typename ImageType::Pointer support = this->template GetInput<ImageType>(0);
87   typename ImageType::Pointer object = this->template GetInput<ImageType>(1);
88   typename ImageType::Pointer target = this->template GetInput<ImageType>(2);
89   filter->SetInputSupport(support);
90   filter->SetInputObject(object);
91   filter->SetInputTarget(target);
92
93   // Set global Options 
94   SetOptionsFromArgsInfoToFilter<FilterType>(filter);
95
96   // Go !
97   filter->Update();
98
99   // Display output
100   std::string s;
101   if (mArgsInfo.afdb_given) {
102     NewAFDB(afdb, mArgsInfo.afdb_arg);
103     std::string patient = afdb->GetTagValue("PatientID");
104     std::string support;
105     std::string object;
106     if (mArgsInfo.objectName_given) object = mArgsInfo.objectName_arg;
107     else object = mArgsInfo.object_arg;
108     if (mArgsInfo.supportName_given) support = mArgsInfo.supportName_arg;
109     else support = mArgsInfo.support_arg;
110     s = patient+" "+support+" "+object+" ";
111   }
112   filter->Print(s, std::cout);
113 }
114 //--------------------------------------------------------------------
115
116