]> Creatis software - clitk.git/blob - itk/clitkAddRelativePositionConstraintToLabelImageFilter.h
Merge branch 'master' of /home/dsarrut/clitk3.server
[clitk.git] / itk / clitkAddRelativePositionConstraintToLabelImageFilter.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 CLITKADDRELATIVEPOSITIONCONSTRAINTTOLABELIMAGEFILTER_H
20 #define CLITKADDRELATIVEPOSITIONCONSTRAINTTOLABELIMAGEFILTER_H
21
22 // clitk
23 #include "clitkFilterBase.h"
24
25 // itk
26 #include <itkPasteImageFilter.h>
27
28 // itk ENST
29 #include "RelativePositionPropImageFilter.h"
30
31 namespace clitk {
32   
33   //--------------------------------------------------------------------
34   /*
35     Let A be an initial label image.
36     Let B be a label image with an object. 
37     Let o be an orientation relatively to the B object (for example RightTo, AntTo, InferiorTo ...)
38
39     This filter removes (=set background) from A all points that are
40     not in the wanted o orientation. It uses downsampled version for
41     faster processing, and (try to) take into account discretization
42     problem. Uses [Bloch 1999].
43   */
44   //--------------------------------------------------------------------
45   
46   template <class ImageType>
47   class ITK_EXPORT AddRelativePositionConstraintToLabelImageFilter:
48     public clitk::FilterBase, 
49     public itk::ImageToImageFilter<ImageType, ImageType> 
50   {
51
52   public:
53     /** Standard class typedefs. */
54     typedef itk::ImageToImageFilter<ImageType, ImageType>      Superclass;
55     typedef AddRelativePositionConstraintToLabelImageFilter    Self;
56     typedef itk::SmartPointer<Self>                            Pointer;
57     typedef itk::SmartPointer<const Self>                      ConstPointer;
58        
59     /** Method for creation through the object factory. */
60     itkNewMacro(Self);
61     
62     /** Run-time type information (and related methods). */
63     itkTypeMacro(AddRelativePositionConstraintToLabelImageFilter, ImageToImageFilter);
64     FILTERBASE_INIT;
65
66     /** Some convenient typedefs. */
67     typedef typename ImageType::ConstPointer ImageConstPointer;
68     typedef typename ImageType::Pointer      ImagePointer;
69     typedef typename ImageType::RegionType   RegionType; 
70     typedef typename ImageType::PixelType    PixelType;
71     typedef typename ImageType::SpacingType  SpacingType;
72     typedef typename ImageType::SizeType     SizeType;
73     typedef typename ImageType::IndexType    IndexType;
74     typedef typename ImageType::PointType    PointType;
75     
76     /** ImageDimension constants */
77     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
78     typedef itk::Image<float, ImageDimension> FloatImageType;
79
80     /** Orientation types */
81     typedef enum { RightTo = 0, LeftTo = 1,
82                    AntTo = 2,   PostTo = 3, 
83                    InfTo = 4,   SupTo = 5, Angle = 6
84     } OrientationTypeEnumeration;
85
86     /** Input : initial image and object */
87     void SetInput(const ImageType * image);
88     void SetInputObject(const ImageType * image);
89     
90     // Options
91     void AddOrientationType(OrientationTypeEnumeration orientation);
92     void AddOrientationTypeString(std::string s);
93     void ClearOrientationType();
94     void AddAngles(double a, double b);
95     int GetNumberOfAngles();
96     std::string GetOrientationTypeString(int i) { return m_OrientationTypeString[i]; }
97     std::vector<std::string> & GetOrientationTypeString() { return m_OrientationTypeString; }
98
99     itkGetConstMacro(IntermediateSpacingFlag, bool);
100     itkSetMacro(IntermediateSpacingFlag, bool);
101     itkBooleanMacro(IntermediateSpacingFlag);
102
103     itkGetConstMacro(IntermediateSpacing, double);
104     itkSetMacro(IntermediateSpacing, double);
105
106     itkGetConstMacro(FuzzyThreshold, double);
107     itkSetMacro(FuzzyThreshold, double);
108
109     itkGetConstMacro(BackgroundValue, PixelType);
110     itkSetMacro(BackgroundValue, PixelType);
111
112     itkGetConstMacro(ObjectBackgroundValue, PixelType);
113     itkSetMacro(ObjectBackgroundValue, PixelType);
114
115     itkGetConstMacro(AutoCropFlag, bool);
116     itkSetMacro(AutoCropFlag, bool);
117     itkBooleanMacro(AutoCropFlag);
118
119     itkGetConstMacro(InverseOrientationFlag, bool);
120     itkSetMacro(InverseOrientationFlag, bool);
121     itkBooleanMacro(InverseOrientationFlag);
122
123     itkGetConstMacro(RemoveObjectFlag, bool);
124     itkSetMacro(RemoveObjectFlag, bool);
125     itkBooleanMacro(RemoveObjectFlag);
126
127     itkGetConstMacro(CombineWithOrFlag, bool);
128     itkSetMacro(CombineWithOrFlag, bool);
129     itkBooleanMacro(CombineWithOrFlag);
130
131     // I dont want to verify inputs information
132     virtual void VerifyInputInformation() { }
133     
134     // For debug
135     void PrintOptions();
136
137   protected:
138     AddRelativePositionConstraintToLabelImageFilter();
139     virtual ~AddRelativePositionConstraintToLabelImageFilter() {}
140     
141     std::vector<OrientationTypeEnumeration> m_OrientationType;
142     std::vector<std::string> m_OrientationTypeString;
143     double m_IntermediateSpacing;
144     double m_FuzzyThreshold;
145     PixelType m_BackgroundValue;
146     PixelType m_ObjectBackgroundValue;
147     std::vector<double> m_Angle1;
148     std::vector<double> m_Angle2;
149     bool m_IntermediateSpacingFlag;
150     bool m_AutoCropFlag;
151     bool m_InverseOrientationFlag;
152     bool m_RemoveObjectFlag;
153     bool m_CombineWithOrFlag;
154
155     virtual void GenerateOutputInformation();
156     virtual void GenerateInputRequestedRegion();
157     virtual void GenerateData();
158
159     typedef itk::PasteImageFilter<ImageType,ImageType> PasteFilterType;
160     typename ImageType::Pointer working_image;
161     typename ImageType::Pointer object_resampled;
162     typename FloatImageType::Pointer relPos;
163     ImagePointer input;
164     ImagePointer object;
165
166   private:
167     AddRelativePositionConstraintToLabelImageFilter(const Self&); //purposely not implemented
168     void operator=(const Self&); //purposely not implemented
169     
170   }; // end class
171   //--------------------------------------------------------------------
172
173 } // end namespace clitk
174 //--------------------------------------------------------------------
175
176 #ifndef ITK_MANUAL_INSTANTIATION
177 #include "clitkAddRelativePositionConstraintToLabelImageFilter.txx"
178 #endif
179
180 #endif