ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkShapedFloodFilledFunctionConditionalConstIterator.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 itkShapedFloodFilledFunctionConditionalConstIterator_h
19#define itkShapedFloodFilledFunctionConditionalConstIterator_h
20
21#include <queue>
22#include <vector>
23
24#include "itkSize.h"
27
28namespace itk
29{
42template <typename TImage, typename TFunction>
44{
45public:
48
50 using FunctionType = TFunction;
51
53 using FunctionInputType = typename TFunction::InputType;
54
56 using IndexType = typename TImage::IndexType;
57
59 using SeedsContainerType = typename std::vector<IndexType>;
60
62 using OffsetType = typename TImage::OffsetType;
63
65 using SizeType = typename TImage::SizeType;
66
68 using RegionType = typename TImage::RegionType;
69
71 using ImageType = TImage;
72
74 using InternalPixelType = typename TImage::InternalPixelType;
75
77 using PixelType = typename TImage::PixelType;
78
79#ifndef ITK_LEGACY_REMOVE
81 using NeighborhoodIteratorType
82 [[deprecated("This nested type alias was only for internal use, and is now obsolete!")]] =
84#endif
85
90 static constexpr unsigned int NDimensions = TImage::ImageDimension;
91
96 FunctionType * fnPtr,
97 IndexType startIndex);
98
103 FunctionType * fnPtr,
104 std::vector<IndexType> & startIndex);
105
110
115 void
117
119 void
121
123 void
125
128
130 bool
131 IsPixelIncluded(const IndexType & index) const override = 0;
132
135 Self &
136 operator=(const Self & it)
137 {
138 this->m_Image = it.m_Image; // copy the smart pointer
139 this->m_Region = it.m_Region;
140 return *this;
141 }
142
144 static unsigned int
146 {
147 return TImage::ImageDimension;
148 }
149
154 const IndexType
155 GetIndex() override
156 {
157 return m_IndexStack.front();
158 }
159
161 const PixelType
162 Get() const override
163 {
164 return this->m_Image->GetPixel(m_IndexStack.front());
165 }
166
168 [[nodiscard]] bool
169 IsAtEnd() const override
170 {
171 return this->m_IsAtEnd;
172 }
173
175 void
176 AddSeed(const IndexType seed)
177 {
178 m_Seeds.push_back(seed);
179 }
180
182 void
184 {
185 m_Seeds.clear();
186 }
187
190 void
192 {
193 // Clear the queue
194 while (!m_IndexStack.empty())
195 {
196 m_IndexStack.pop();
197 }
198
199 this->m_IsAtEnd = true;
200 // Initialize the temporary image
201 m_TempPtr->FillBuffer(typename TTempImage::PixelType{});
202
203 for (unsigned int i = 0; i < m_Seeds.size(); ++i)
204 {
205 if (this->m_Image->GetBufferedRegion().IsInside(m_Seeds[i]) && this->IsPixelIncluded(m_Seeds[i]))
206 {
207 // Push the seed onto the queue
208 m_IndexStack.push(m_Seeds[i]);
209
210 // Obviously, we're at the beginning
211 this->m_IsAtEnd = false;
212
213 // Mark the start index in the temp image as inside the
214 // function, neighbor check incomplete
215 m_TempPtr->SetPixel(m_Seeds[i], 2);
216 }
217 }
218 }
219
221 void
222 operator++() override
223 {
224 this->DoFloodStep();
225 }
226
227 void
229
232 {
233 return m_Function;
234 }
235
240 void
241 SetFullyConnected(const bool _arg);
242
243 [[nodiscard]] bool
245
246 itkBooleanMacro(FullyConnected);
247
248 virtual const SeedsContainerType &
249 GetSeeds() const
250 {
251 return m_Seeds;
252 }
253
254protected: // made protected so other iterators can access
257
264
266
269
271 typename ImageType::PointType m_ImageOrigin{};
272
274 typename ImageType::SpacingType m_ImageSpacing{};
275
278
281
283 std::queue<IndexType> m_IndexStack{};
284
287
291
294
301};
302} // end namespace itk
303
304#ifndef ITK_MANUAL_INSTANTIATION
305# include "itkShapedFloodFilledFunctionConditionalConstIterator.hxx"
306#endif
307
308#endif
Const version of ShapedNeighborhoodIterator, defining iteration of a local N-dimensional neighborhood...
Templated n-dimensional image class.
Definition itkImage.h:89
Iterates over a flood-filled spatial function with read-only access to pixels.
ShapedFloodFilledFunctionConditionalConstIterator(const ImageType *imagePtr, FunctionType *fnPtr)
ShapedFloodFilledFunctionConditionalConstIterator(const ImageType *imagePtr, FunctionType *fnPtr, std::vector< IndexType > &startIndex)
bool IsPixelIncluded(const IndexType &index) const override=0
ShapedFloodFilledFunctionConditionalConstIterator(const ImageType *imagePtr, FunctionType *fnPtr, IndexType startIndex)
A neighborhood iterator which can take on an arbitrary shape.
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....