ITK  4.13.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 #include "itkImage.h"
25 
26 namespace itk
27 {
88 template< unsigned int VDimension >
89 class ITK_TEMPLATE_EXPORT FlatStructuringElement:public Neighborhood< bool, VDimension >
90 {
91 public:
95 
97  typedef typename Superclass::PixelType PixelType;
98 
102  typedef typename Superclass::Iterator Iterator;
104 
106  typedef typename Superclass::SizeType SizeType;
108 
110  typedef typename Superclass::RadiusType RadiusType;
111 
114 
116  itkStaticConstMacro(NeighborhoodDimension, unsigned int, VDimension);
117 
119  typedef std::vector< LType > DecompType;
120 
123 
125  virtual ~FlatStructuringElement() ITK_OVERRIDE {}
126 
129  {
130  m_Decomposable = false;
131  m_RadiusIsParametric = false;
132  }
133 
140  static Self Box(RadiusType radius);
141 
143  static Self Ball(RadiusType radius, bool radiusIsParametric = false);
144 
146  static Self Cross(RadiusType radius);
147 
149  static Self Annulus(RadiusType radius,
150  unsigned int thickness = 1,
151  bool includeCenter = false,
152  bool radiusIsParametric = false);
153 
159  static Self Polygon(RadiusType radius, unsigned lines);
160 
166  bool GetDecomposable() const
167  {
168  return m_Decomposable;
169  }
170  void SetDecomposable( bool v )
171  {
172  m_Decomposable = v;
173  }
175 
177  const DecompType & GetLines() const
178  {
179  return ( m_Lines );
180  }
181  void AddLine( LType l )
182  {
183  m_Lines.push_back(l);
184  }
186 
187  bool CheckParallel(LType NewVec) const;
188 
193  void ComputeBufferFromLines();
194 
201  {
202  return m_RadiusIsParametric;
203  }
204  void SetRadiusIsParametric( bool flag )
205  {
206  m_RadiusIsParametric = flag;
207  }
208  itkBooleanMacro(RadiusIsParametric);
210 
213  static Self FromImage(const ImageType * image);
214 
215 protected:
216 
217  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
218 
219 private:
221 
223 
224  template< unsigned int VDimension3 >
227  };
229 
230  template<typename TStructuringElement, typename TRadius>
231  static void GeneratePolygon(TStructuringElement & res, TRadius radius, unsigned lines);
232  static void GeneratePolygon(itk::FlatStructuringElement<2> & res, itk::Size<2> radius, unsigned lines);
233  static void GeneratePolygon(itk::FlatStructuringElement<3> & res, itk::Size<3> radius, unsigned lines);
234 
236 
239 
241 
244  static RadiusType CheckImageSize(const ImageType * image);
245 };
246 } // namespace itk
247 
248 #ifndef ITK_MANUAL_INSTANTIATION
249 #include "itkFlatStructuringElement.hxx"
250 #endif
251 
252 #endif
itk::Image< PixelType, VDimension > ImageType
FlatStructuringElement< VDimension > Self
Compute the cross product of two vectors of dimension 3, independently of the type of the values of v...
Neighborhood< bool, VDimension > Superclass
StructuringElementFacet< VDimension > FacetType
Superclass::SliceIteratorType SliceIteratorType
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
A flexible iterator for itk containers(i.e. itk::Neighborhood) that support pixel access through oper...
A class to support a variety of flat structuring elements, including versions created by decompositio...
Vector< float, VDimension > LType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
AllocatorType::const_iterator ConstIterator
StructuringElementFacet< 3 > FacetType3
const DecompType & GetLines() const
Templated n-dimensional image class.
Definition: itkImage.h:75
Superclass::ConstIterator ConstIterator