]> Creatis software - clitk.git/blob - tools/clitkRelativePositionAnalyzerGenericFilter.txx
GateAsciiImageIO is now cross-platform using itksys::RegularExpression
[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->SetNumberOfBins(mArgsInfo.bins_arg);
68   f->SetAreaLossTolerance(mArgsInfo.tol_arg);
69   clitk::RelativePositionDirectionType d;
70   if (mArgsInfo.angle1_given) d.angle1 = clitk::deg2rad(mArgsInfo.angle1_arg);
71   if (mArgsInfo.angle2_given) d.angle2 = clitk::deg2rad(mArgsInfo.angle2_arg);
72   if (mArgsInfo.inverse_given) d.notFlag = clitk::deg2rad(mArgsInfo.inverse_flag);
73   f->SetDirection(d);
74 }
75 //--------------------------------------------------------------------
76
77
78 //--------------------------------------------------------------------
79 // Update with the number of dimensions and the pixeltype
80 //--------------------------------------------------------------------
81 template<class ArgsInfoType>
82 template<class ImageType>
83 void clitk::RelativePositionAnalyzerGenericFilter<ArgsInfoType>::
84 UpdateWithInputImageType() 
85
86   // Create filter
87   typedef clitk::RelativePositionAnalyzerFilter<ImageType> FilterType;
88   typename FilterType::Pointer filter = FilterType::New();
89   
90   // Reading input
91   typename ImageType::Pointer support = this->template GetInput<ImageType>(0);
92   typename ImageType::Pointer object = this->template GetInput<ImageType>(1);
93   typename ImageType::Pointer target = this->template GetInput<ImageType>(2);
94   filter->SetInputSupport(support);
95   filter->SetInputObject(object);
96   filter->SetInputTarget(target);
97
98   // Set global Options 
99   SetOptionsFromArgsInfoToFilter<FilterType>(filter);
100
101   // Go !
102   filter->Update();
103
104   // Display output
105   filter->GetInfo().Println();
106   filter->GetInfoReverse().Println();
107 }
108 //--------------------------------------------------------------------
109
110