]> Creatis software - clitk.git/blob - segmentation/clitkMorphoMathFilter.h
Debug RTStruct conversion with empty struc
[clitk.git] / segmentation / clitkMorphoMathFilter.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 CLITKMORPHOMATHFILTER_H
20 #define CLITKMORPHOMATHFILTER_H
21
22 // clitk include
23 #include "clitkIO.h"
24 #include "clitkImageCommon.h"
25 #include "clitkConditionalBinaryErodeImageFilter.h"
26 #include "clitkConditionalBinaryDilateImageFilter.h"
27
28 // itk include
29 #include <itkLightObject.h>
30 #include <itkBinaryErodeImageFilter.h>
31 #include <itkBinaryDilateImageFilter.h>
32 #include <itkBinaryMorphologicalClosingImageFilter.h>
33 #include <itkBinaryMorphologicalOpeningImageFilter.h>
34 #include <itkBinaryBallStructuringElement.h>
35 #include <itkCastImageFilter.h>
36
37 namespace clitk {
38
39   //--------------------------------------------------------------------
40   template<class ImageType>
41   class ITK_EXPORT MorphoMathFilter:
42     public clitk::FilterBase,
43     public itk::ImageToImageFilter<ImageType, ImageType>
44   {
45
46   public:
47     /** Standard class typedefs. */
48     typedef itk::ImageToImageFilter<ImageType, ImageType> Superclass;
49     typedef MorphoMathFilter<ImageType>                   Self;
50     typedef itk::SmartPointer<Self>                       Pointer;
51     typedef itk::SmartPointer<const Self>                 ConstPointer;
52
53     /** Method for creation through the object factory. */
54     itkNewMacro(Self);
55
56     /** Run-time type information (and related methods). */
57     itkTypeMacro(AddRelativePositionConstraintToLabelImageFilter, ImageToImageFilter);
58     FILTERBASE_INIT;
59
60     /** Some convenient typedefs. */
61     typedef typename ImageType::ConstPointer ImageConstPointer;
62     typedef typename ImageType::Pointer      ImagePointer;
63     typedef typename ImageType::RegionType   RegionType;
64     typedef typename ImageType::PixelType    PixelType;
65     typedef typename ImageType::SpacingType  SpacingType;
66     typedef typename ImageType::SizeType     SizeType;
67     typedef typename ImageType::IndexType    IndexType;
68     typedef typename ImageType::PointType    PointType;
69     typedef float InternalPixelType;
70     typedef itk::Image<InternalPixelType, ImageType::ImageDimension> InternalImageType;
71
72     /** ImageDimension constants */
73     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
74     typedef itk::Image<float, ImageDimension> FloatImageType;
75
76     /** Operation types */
77     typedef enum { Erode     = 0, Dilate     = 1,
78                    Close     = 2, Open       = 3,
79                    CondErode = 4, CondDilate = 5
80     } OperationTypeEnumeration;
81
82     /** Options */
83     itkGetConstMacro(VerboseFlag, bool);
84     itkSetMacro(VerboseFlag, bool);
85     itkBooleanMacro(VerboseFlag);
86
87     itkGetConstMacro(BackgroundValue, PixelType);
88     itkSetMacro(BackgroundValue, PixelType);
89
90     itkGetConstMacro(ForegroundValue, PixelType);
91     itkSetMacro(ForegroundValue, PixelType);
92
93     void SetOperationType(int type);
94
95     itkGetConstMacro(RadiusInMM, PointType);
96     void SetRadiusInMM(PointType & p);
97
98     itkGetConstMacro(Radius, SizeType);
99     void SetRadius(SizeType & r);
100     void SetRadius(int r);
101
102     itkGetConstMacro(BoundaryToForegroundFlag, bool);
103     itkSetMacro(BoundaryToForegroundFlag, bool);
104     itkBooleanMacro(BoundaryToForegroundFlag);
105
106     itkGetConstMacro(ExtendSupportFlag, bool);
107     itkSetMacro(ExtendSupportFlag, bool);
108     itkBooleanMacro(ExtendSupportFlag);
109
110   protected:
111     MorphoMathFilter();
112     virtual ~MorphoMathFilter();
113
114     bool m_VerboseFlag;
115     PixelType m_BackgroundValue;
116     PixelType m_ForegroundValue;
117     PointType m_RadiusInMM;
118     SizeType  m_Radius;
119     bool m_RadiusInMMIsSet;
120     bool m_RadiusIsSet;
121     OperationTypeEnumeration m_OperationType;
122     bool m_BoundaryToForegroundFlag;
123     bool m_ExtendSupportFlag;
124     typename InternalImageType::Pointer input;
125
126     virtual void GenerateOutputInformation();
127     virtual void GenerateInputRequestedRegion();
128     virtual void GenerateData();
129
130   private:
131     MorphoMathFilter(const Self&); //purposely not implemented
132     void operator=(const Self&); //purposely not implemented
133   };
134
135 } // end namespace clitk
136 #ifndef ITK_MANUAL_INSTANTIATION
137 #include "clitkMorphoMathFilter.txx"
138 #endif
139
140 #endif //#define CLITKMORPHOMATHFILTER_H