ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkFlatStructuringElement.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkFlatStructuringElement_h
19 #define __itkFlatStructuringElement_h
20 
21 #include "itkNeighborhood.h"
22 #include <vector>
23 #include "itkVector.h"
24 
25 namespace itk
26 {
44 template< unsigned int VDimension >
45 class ITK_EXPORT FlatStructuringElement:public Neighborhood< bool, VDimension >
46 {
47 public:
51 
53  typedef typename Superclass::PixelType PixelType;
54 
58  typedef typename Superclass::Iterator Iterator;
60 
62  typedef typename Superclass::SizeType SizeType;
64 
66  typedef typename Superclass::RadiusType RadiusType;
67 
70 
72  itkStaticConstMacro(NeighborhoodDimension, unsigned int, VDimension);
73 
75  typedef std::vector< LType > DecompType;
76 
79 
81  FlatStructuringElement() { m_Decomposable = false; }
82 
89  static Self Box(RadiusType radius);
90 
92  static Self Ball(RadiusType radius);
93 
95  static Self Cross(RadiusType radius);
96 
98  static Self Annulus(RadiusType radius,
99  unsigned int thickness = 1,
100  bool includeCenter = false);
101 
107  static Self Polygon(RadiusType radius, unsigned lines);
108 
114  bool GetDecomposable() const
115  {
116  return m_Decomposable;
117  }
118  void SetDecomposable( bool v )
119  {
120  m_Decomposable = v;
121  }
123 
125  const DecompType & GetLines() const
126  {
127  return ( m_Lines );
128  }
129  void AddLine( LType l )
130  {
131  m_Lines.push_back(l);
132  }
134 
135  bool CheckParallel(LType NewVec) const;
136 
141  void ComputeBufferFromLines();
142 
143 protected:
144 
145  void PrintSelf(std::ostream & os, Indent indent) const;
146 
147 private:
149 
151 
152  template< unsigned int VDimension3 >
155  };
157 
158  template<class TStructuringElement, class TRadius>
159  static void GeneratePolygon(TStructuringElement & res, TRadius radius, unsigned lines);
160  static void GeneratePolygon(itk::FlatStructuringElement<2> & res, itk::Size<2> radius, unsigned lines);
161  static void GeneratePolygon(itk::FlatStructuringElement<3> & res, itk::Size<3> radius, unsigned lines);
162 
164 
167 
168 };
169 } // namespace itk
170 
171 #ifndef ITK_MANUAL_INSTANTIATION
172 #include "itkFlatStructuringElement.hxx"
173 #endif
174 
175 #endif
176