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
26namespace itk
27{
87template <unsigned int VDimension>
88class ITK_TEMPLATE_EXPORT FlatStructuringElement : public Neighborhood<bool, VDimension>
89{
90public:
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;
115 static constexpr unsigned int NeighborhoodDimension = VDimension;
118 using DecompType = std::vector<LType>;
124 ~FlatStructuringElement() override = default;
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
168 GetDecomposable() const
169 {
170 return m_Decomposable;
172 void
173 SetDecomposable(bool v)
174 {
175 m_Decomposable = v;
176 }
180 const DecompType &
181 GetLines() const
182 {
183 return (m_Lines);
185 void
186 AddLine(LType l)
187 {
188 m_Lines.push_back(l);
189 }
192 bool
193 CheckParallel(LType NewVec) const;
194
199 void
200 ComputeBufferFromLines();
201
207 bool
208 GetRadiusIsParametric() const
209 {
210 return m_RadiusIsParametric;
212 void
213 SetRadiusIsParametric(bool flag)
214 {
215 m_RadiusIsParametric = flag;
216 }
217 itkBooleanMacro(RadiusIsParametric);
222 static Self
223 FromImage(const ImageType * image);
224
225protected:
226 void
227 PrintSelf(std::ostream & os, Indent indent) const override;
229private:
230 bool m_Decomposable{};
231
232 DecompType m_Lines{};
234 template <unsigned int VDimension3>
236 {
238 };
239 using FacetType = StructuringElementFacet<VDimension>;
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
249 using LType3 = Vector<float, 3>;
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
Pixel-wise addition of two images.
Compute the cross product of two vectors of dimension 3, independently of the type of the values of v...
A class to support a variety of flat structuring elements, including versions created by decompositio...
static void GeneratePolygon(itk::FlatStructuringElement< 3 > &res, itk::Size< 3 > radius, unsigned int lines)
typename itk::Image< PixelType, VDimension > ImageType
Templated n-dimensional image class.
Definition: itkImage.h:89
Control indentation during Print() invocation.
Definition: itkIndent.h:50
typename AllocatorType::iterator Iterator
typename AllocatorType::const_iterator ConstIterator
A flexible iterator for itk containers(i.e. itk::Neighborhood) that support pixel access through oper...
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:63
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....