]> Creatis software - clitk.git/blob - itk/clitkRelativePositionDataBaseBuilderFilter.h
motion masks with and without bands
[clitk.git] / itk / clitkRelativePositionDataBaseBuilderFilter.h
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 #ifndef CLITKRelativePositionDataBaseBuilderFILTER_H
20 #define CLITKRelativePositionDataBaseBuilderFILTER_H
21
22 // clitk
23 #include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
24 #include "clitkFilterBase.h"
25 #include "clitkRelativePositionAnalyzerFilter.h"
26 #include "clitkRelativePositionDataBase.h"
27
28 // itk
29 #include <itkImageToImageFilter.h>
30
31 namespace clitk {
32   
33   //--------------------------------------------------------------------
34   /*
35     Analyze the relative position of a Target (mask image) according
36     to some Object, in a given Support. Indicate the main important
37     position of this Target according the Object. 
38   */
39   //--------------------------------------------------------------------
40   
41   template <class ImageType>
42   class RelativePositionDataBaseBuilderFilter:
43     public virtual FilterBase,
44     public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
45     public itk::ImageToImageFilter<ImageType, ImageType>
46   {
47
48   public:
49     /** Standard class typedefs. */
50     typedef itk::ImageToImageFilter<ImageType, ImageType>      Superclass;
51     typedef RelativePositionDataBaseBuilderFilter<ImageType>          Self;
52     typedef itk::SmartPointer<Self>                            Pointer;
53     typedef itk::SmartPointer<const Self>                      ConstPointer;
54        
55     /** Method for creation through the object factory. */
56     itkNewMacro(Self);
57     
58     /** Run-time type information (and related methods). */
59     itkTypeMacro(RelativePositionDataBaseBuilderFilter, ImageToImageFilter);
60
61     /** Some convenient typedefs. */
62     typedef typename ImageType::ConstPointer ImageConstPointer;
63     typedef typename ImageType::Pointer      ImagePointer;
64     typedef typename ImageType::RegionType   RegionType; 
65     typedef typename ImageType::PixelType    PixelType;
66     typedef typename ImageType::SpacingType  SpacingType;
67     typedef typename ImageType::SizeType     SizeType;
68     typedef typename ImageType::IndexType    IndexType;
69     typedef typename ImageType::PointType    PointType;
70     
71     /** ImageDimension constants */
72     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
73     FILTERBASE_INIT;
74     typedef itk::Image<float, ImageDimension> FloatImageType;
75    
76     // Inputs
77     itkGetConstMacro(SupportName, std::string);
78     itkSetMacro(SupportName, std::string);
79
80     itkGetConstMacro(TargetName, std::string);
81     itkSetMacro(TargetName, std::string);
82
83     void AddObjectName(std::string s) { m_ObjectNames.push_back(s); }
84     std::string & GetObjectName(int i) { return m_ObjectNames[i]; }
85     int GetNumberOfObjects() { return m_ObjectNames.size(); }
86
87     // Options   
88     itkGetConstMacro(BackgroundValue, PixelType);
89     itkSetMacro(BackgroundValue, PixelType);
90
91     itkGetConstMacro(ForegroundValue, PixelType);
92     itkSetMacro(ForegroundValue, PixelType);
93     
94     itkGetConstMacro(NumberOfBins, int);
95     itkSetMacro(NumberOfBins, int);
96
97     itkGetConstMacro(NumberOfAngles, int);
98     itkSetMacro(NumberOfAngles, int);
99
100     itkGetConstMacro(AreaLossTolerance, double);
101     itkSetMacro(AreaLossTolerance, double);
102
103     // For debug
104     void PrintOptions();
105
106     // I dont want to verify inputs information
107     virtual void VerifyInputInformation() { }
108     
109    protected:
110     RelativePositionDataBaseBuilderFilter();
111     virtual ~RelativePositionDataBaseBuilderFilter() {}
112     
113     PixelType m_BackgroundValue;
114     PixelType m_ForegroundValue;
115
116     ImagePointer m_Support;
117     ImagePointer m_Object;
118     ImagePointer m_Target;
119
120     std::string m_SupportName;
121     std::string m_TargetName;
122     std::vector<std::string> m_ObjectNames;
123
124     int m_NumberOfAngles;
125     std::vector<double> m_ListOfAngles;
126     std::vector<clitk::RelativePositionDirectionType> m_ListOfDirections;
127
128     int m_NumberOfBins;
129     double m_AreaLossTolerance;
130     
131     virtual void GenerateOutputInformation();
132     virtual void GenerateInputRequestedRegion();
133     virtual void GenerateData();
134
135     typename FloatImageType::Pointer
136     ComputeFuzzyMap(ImageType * object, ImageType * target, double angle);
137     
138     void
139     ComputeOptimalThresholds(FloatImageType * map, ImageType * target, int bins, double tolerance, 
140                              double & threshold, double & reverseThreshold);
141   private:
142     RelativePositionDataBaseBuilderFilter(const Self&); //purposely not implemented
143     void operator=(const Self&); //purposely not implemented
144     
145   }; // end class
146   //--------------------------------------------------------------------
147
148 } // end namespace clitk
149 //--------------------------------------------------------------------
150
151 #include "clitkRelativePositionDataBaseBuilderFilter.txx"
152
153 #endif