]> Creatis software - clitk.git/blob - itk/clitkRelativePositionAnalyzerFilter.h
First version of RelativePositionAnalyzer
[clitk.git] / itk / clitkRelativePositionAnalyzerFilter.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 CLITKRELATIVEPOSITIONANALYZERFILTER_H
20 #define CLITKRELATIVEPOSITIONANALYZERFILTER_H
21
22 // clitk
23 #include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
24 #include "clitkFilterBase.h"
25 #include "clitkSliceBySliceRelativePositionFilter.h"
26
27 // itk
28 #include <itkImageToImageFilter.h>
29 #include <itkLabelStatisticsImageFilter.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 RelativePositionAnalyzerFilter:
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 RelativePositionAnalyzerFilter<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(RelativePositionAnalyzerFilter, 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      /** Input : initial image and object */
77     void SetInputSupport(const ImageType * image);
78     void SetInputObject(const ImageType * image);
79     void SetInputTarget(const ImageType * image);
80     
81     // Options
82     itkGetConstMacro(BackgroundValue, PixelType);
83     itkSetMacro(BackgroundValue, PixelType);
84
85     itkGetConstMacro(ForegroundValue, PixelType);
86     itkSetMacro(ForegroundValue, PixelType);
87
88     // For debug
89     void PrintOptions();
90
91     // I dont want to verify inputs information
92     virtual void VerifyInputInformation() { }
93     
94    protected:
95     RelativePositionAnalyzerFilter();
96     virtual ~RelativePositionAnalyzerFilter() {}
97     
98     PixelType m_BackgroundValue;
99     PixelType m_ForegroundValue;
100     ImagePointer m_Support;
101     ImagePointer m_Object;
102     ImagePointer m_Target;
103
104     virtual void GenerateOutputInformation();
105     virtual void GenerateInputRequestedRegion();
106     virtual void GenerateData();
107
108     typename FloatImageType::Pointer
109     ComputeFuzzyMap(ImageType * object, ImageType * target, double angle);
110     
111     void
112     ComputeOptimalThresholds(FloatImageType * map, ImageType * target, int bins, double tolerance, 
113                              double & threshold, double & reverseThreshold);
114   private:
115     RelativePositionAnalyzerFilter(const Self&); //purposely not implemented
116     void operator=(const Self&); //purposely not implemented
117     
118   }; // end class
119   //--------------------------------------------------------------------
120
121 } // end namespace clitk
122 //--------------------------------------------------------------------
123
124 #include "clitkRelativePositionAnalyzerFilter.txx"
125
126 #endif