ITK  6.0.0
Insight Toolkit
itkFlatStructuringElement.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 {
87 template <unsigned int VDimension>
88 class ITK_TEMPLATE_EXPORT FlatStructuringElement : public Neighborhood<bool, VDimension>
89 {
90 public:
94 
96  using typename Superclass::PixelType;
97 
101  using typename Superclass::Iterator;
102  using typename Superclass::ConstIterator;
103 
105  using typename Superclass::SizeType;
106  using typename Superclass::OffsetType;
107 
109  using typename Superclass::RadiusType;
110 
112  using typename Superclass::SliceIteratorType;
113 
115  static constexpr unsigned int NeighborhoodDimension = VDimension;
116 
118  using DecompType = std::vector<LType>;
119 
122 
124  ~FlatStructuringElement() override = default;
125 
128  {
129  m_Decomposable = false;
130  m_RadiusIsParametric = false;
131  }
132 
139  static Self
140  Box(RadiusType radius);
141 
143  static Self
144  Ball(RadiusType radius, bool radiusIsParametric = false);
145 
147  static Self
148  Cross(RadiusType radius);
149 
151  static Self
152  Annulus(RadiusType radius, unsigned int thickness = 1, bool includeCenter = false, bool radiusIsParametric = false);
153 
159  static Self
160  Polygon(RadiusType radius, unsigned int lines);
161 
167  bool
169  {
170  return m_Decomposable;
171  }
172  void
174  {
175  m_Decomposable = v;
176  }
180  const DecompType &
181  GetLines() const
182  {
183  return (m_Lines);
184  }
185  void
187  {
188  m_Lines.push_back(l);
189  }
192  bool
193  CheckParallel(LType NewVec) const;
194 
199  void
200  ComputeBufferFromLines();
201 
207  bool
209  {
210  return m_RadiusIsParametric;
211  }
212  void
214  {
215  m_RadiusIsParametric = flag;
216  }
217  itkBooleanMacro(RadiusIsParametric);
222  static Self
223  FromImage(const ImageType * image);
224 
225 protected:
226  void
227  PrintSelf(std::ostream & os, Indent indent) const override;
228 
229 private:
230  bool m_Decomposable{};
231 
232  DecompType m_Lines{};
233 
234  template <unsigned int VDimension3>
236  {
238  };
240 
241  template <typename TStructuringElement, typename TRadius>
242  static void
243  GeneratePolygon(TStructuringElement & res, TRadius radius, unsigned int lines);
244  static void GeneratePolygon(itk::FlatStructuringElement<2> & res, itk::Size<2> radius, unsigned int lines);
245  static void GeneratePolygon(itk::FlatStructuringElement<3> & res, itk::Size<3> radius, unsigned int lines);
246 
248 
251 
252  bool m_RadiusIsParametric{};
253 
256  static RadiusType
257  CheckImageSize(const ImageType * image);
258 };
259 } // namespace itk
260 
261 #ifndef ITK_MANUAL_INSTANTIATION
262 # include "itkFlatStructuringElement.hxx"
263 #endif
264 
265 #endif
itk::FlatStructuringElement::SetDecomposable
void SetDecomposable(bool v)
Definition: itkFlatStructuringElement.h:173
itk::Size
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:69
itk::SliceIterator
A flexible iterator for itk containers(i.e. itk::Neighborhood) that support pixel access through oper...
Definition: itkSliceIterator.h:48
itk::FlatStructuringElement::StructuringElementFacet
Definition: itkFlatStructuringElement.h:235
itk::FlatStructuringElement
A class to support a variety of flat structuring elements, including versions created by decompositio...
Definition: itkKernelImageFilter.h:27
itk::FlatStructuringElement::ImageType
typename itk::Image< PixelType, VDimension > ImageType
Definition: itkFlatStructuringElement.h:121
itk::FlatStructuringElement::DecompType
std::vector< LType > DecompType
Definition: itkFlatStructuringElement.h:118
itk::Vector
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
itk::Neighborhood< bool, VDimension >
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itkImage.h
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::FlatStructuringElement::SetRadiusIsParametric
void SetRadiusIsParametric(bool flag)
Definition: itkFlatStructuringElement.h:213
itk::FlatStructuringElement::GetLines
const DecompType & GetLines() const
Definition: itkFlatStructuringElement.h:181
itkNeighborhood.h
itk::FlatStructuringElement::AddLine
void AddLine(LType l)
Definition: itkFlatStructuringElement.h:186
itk::Neighborhood< bool, VDimension >::Iterator
typename AllocatorType::iterator Iterator
Definition: itkNeighborhood.h:75
itk::Neighborhood< bool, VDimension >::PixelType
bool PixelType
Definition: itkNeighborhood.h:70
itk::Neighborhood< bool, VDimension >::ConstIterator
typename AllocatorType::const_iterator ConstIterator
Definition: itkNeighborhood.h:76
itk::Offset
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image.
Definition: itkOffset.h:66
itk::FlatStructuringElement::StructuringElementFacet::P3
Vector< float, VDimension3 > P3
Definition: itkFlatStructuringElement.h:237
Cross
Compute the cross product of two vectors of dimension 3, independently of the type of the values of v...
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itkVector.h
itk::FlatStructuringElement::FlatStructuringElement
FlatStructuringElement()
Definition: itkFlatStructuringElement.h:127
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
AddImageFilter
Definition: itkAddImageFilter.h:81
itk::FlatStructuringElement::GetRadiusIsParametric
bool GetRadiusIsParametric() const
Definition: itkFlatStructuringElement.h:208
itk::FlatStructuringElement::GetDecomposable
bool GetDecomposable() const
Definition: itkFlatStructuringElement.h:168