ITK  5.2.0
Insight Toolkit
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  * 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 itkShapedFloodFilledFunctionConditionalConstIterator_h
19 #define itkShapedFloodFilledFunctionConditionalConstIterator_h
20 
21 #include <queue>
22 #include <vector>
23 
24 #include "itkSize.h"
27 
28 namespace itk
29 {
42 template <typename TImage, typename TFunction>
44 {
45 public:
46 
49 
51  using FunctionType = TFunction;
52 
54  using FunctionInputType = typename TFunction::InputType;
55 
57  using IndexType = typename TImage::IndexType;
58 
60  using SeedsContainerType = typename std::vector<IndexType>;
61 
63  using OffsetType = typename TImage::OffsetType;
64 
66  using SizeType = typename TImage::SizeType;
67 
69  using RegionType = typename TImage::RegionType;
70 
72  using ImageType = TImage;
73 
75  using InternalPixelType = typename TImage::InternalPixelType;
76 
78  using PixelType = typename TImage::PixelType;
79 
82 
87  static constexpr unsigned int NDimensions = TImage::ImageDimension;
88 
93  FunctionType * fnPtr,
94  IndexType startIndex);
95 
100  FunctionType * fnPtr,
101  std::vector<IndexType> & startIndex);
102 
107 
112  void
113  FindSeedPixel();
114 
116  void
117  FindSeedPixels();
118 
120  void
121  InitializeIterator();
122 
125 
127  bool
128  IsPixelIncluded(const IndexType & index) const override = 0;
129 
132  Self &
133  operator=(const Self & it)
134  {
135  this->m_Image = it.m_Image; // copy the smart pointer
136  this->m_Region = it.m_Region;
137  return *this;
138  }
139 
141  static unsigned int
143  {
144  return TImage::ImageDimension;
145  }
146 
151  const IndexType
152  GetIndex() override
153  {
154  return m_IndexStack.front();
155  }
156 
158  const PixelType
159  Get() const override
160  {
161  return this->m_Image->GetPixel(m_IndexStack.front());
162  }
163 
165  bool
166  IsAtEnd() const override
167  {
168  return this->m_IsAtEnd;
169  }
170 
172  void
173  AddSeed(const IndexType seed)
174  {
175  m_Seeds.push_back(seed);
176  }
177 
179  void
181  {
182  m_Seeds.clear();
183  }
184 
187  void
189  {
190  // Clear the queue
191  while (!m_IndexStack.empty())
192  {
193  m_IndexStack.pop();
194  }
195 
196  this->m_IsAtEnd = true;
197  // Initialize the temporary image
199 
200  for (unsigned int i = 0; i < m_Seeds.size(); i++)
201  {
202  if (this->m_Image->GetBufferedRegion().IsInside(m_Seeds[i]) && this->IsPixelIncluded(m_Seeds[i]))
203  {
204  // Push the seed onto the queue
205  m_IndexStack.push(m_Seeds[i]);
206 
207  // Obviously, we're at the beginning
208  this->m_IsAtEnd = false;
209 
210  // Mark the start index in the temp image as inside the
211  // function, neighbor check incomplete
212  m_TempPtr->SetPixel(m_Seeds[i], 2);
213  }
214  }
215  }
216 
218  void
219  operator++() override
220  {
221  this->DoFloodStep();
222  }
223 
224  void
225  DoFloodStep();
226 
228  GetFunction() const
229  {
230  return m_Function;
231  }
232 
237  void
238  SetFullyConnected(const bool _arg);
239 
240  bool
241  GetFullyConnected() const;
242 
243  itkBooleanMacro(FullyConnected);
244 
245  virtual const SeedsContainerType &
246  GetSeeds() const
247  {
248  return m_Seeds;
249  }
250 
251 protected: // made protected so other iterators can access
254 
261 
263 
266 
269 
271  typename ImageType::SpacingType m_ImageSpacing;
272 
275 
278 
280  std::queue<IndexType> m_IndexStack;
281 
284 
288 
291 
298 };
299 } // end namespace itk
301 
302 #ifndef ITK_MANUAL_INSTANTIATION
303 # include "itkShapedFloodFilledFunctionConditionalConstIterator.hxx"
304 #endif
305 
306 #endif
itk::ShapedFloodFilledFunctionConditionalConstIterator::OffsetType
typename TImage::OffsetType OffsetType
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:63
itk::ConditionalConstIterator::m_Region
RegionType m_Region
Definition: itkConditionalConstIterator.h:118
itk::ShapedFloodFilledFunctionConditionalConstIterator::GoToBegin
void GoToBegin()
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:188
itk::ShapedFloodFilledFunctionConditionalConstIterator::ImageType
TImage ImageType
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:72
itk::ShapedFloodFilledFunctionConditionalConstIterator::IndexType
typename TImage::IndexType IndexType
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:57
itk::ShapedFloodFilledFunctionConditionalConstIterator::SeedsContainerType
typename std::vector< IndexType > SeedsContainerType
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:60
itk::ShapedFloodFilledFunctionConditionalConstIterator::m_FullyConnected
bool m_FullyConnected
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:297
itk::ShapedFloodFilledFunctionConditionalConstIterator::GetSeeds
virtual const SeedsContainerType & GetSeeds() const
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:246
itk::ShapedFloodFilledFunctionConditionalConstIterator::m_ImageOrigin
ImageType::PointType m_ImageOrigin
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:268
itk::ShapedFloodFilledFunctionConditionalConstIterator::m_IndexStack
std::queue< IndexType > m_IndexStack
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:280
itkConnectedComponentAlgorithm.h
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< FunctionType >
itk::ShapedFloodFilledFunctionConditionalConstIterator::AddSeed
void AddSeed(const IndexType seed)
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:173
itk::ShapedFloodFilledFunctionConditionalConstIterator::m_ImageRegion
RegionType m_ImageRegion
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:277
itk::ShapedNeighborhoodIterator< ImageType >
itk::ShapedFloodFilledFunctionConditionalConstIterator::NeighborhoodIteratorType
typename itk::ShapedNeighborhoodIterator< ImageType > NeighborhoodIteratorType
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:81
itk::ShapedFloodFilledFunctionConditionalConstIterator::RegionType
typename TImage::RegionType RegionType
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:69
itk::ShapedFloodFilledFunctionConditionalConstIterator::operator++
void operator++() override
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:219
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ShapedFloodFilledFunctionConditionalConstIterator
Iterates over a flood-filled spatial function with read-only access to pixels.
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:43
itk::ShapedFloodFilledFunctionConditionalConstIterator::IsAtEnd
bool IsAtEnd() const override
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:166
itk::ConditionalConstIterator::m_Image
ImageType::ConstWeakPointer m_Image
Definition: itkConditionalConstIterator.h:115
itk::ShapedFloodFilledFunctionConditionalConstIterator::InternalPixelType
typename TImage::InternalPixelType InternalPixelType
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:75
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ShapedFloodFilledFunctionConditionalConstIterator::GetIteratorDimension
static unsigned int GetIteratorDimension()
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:142
itk::ShapedFloodFilledFunctionConditionalConstIterator::m_Seeds
SeedsContainerType m_Seeds
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:265
itk::ShapedFloodFilledFunctionConditionalConstIterator::operator=
Self & operator=(const Self &it)
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:133
itk::ShapedFloodFilledFunctionConditionalConstIterator::GetIndex
const IndexType GetIndex() override
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:152
itk::ConditionalConstIterator::SizeType
typename TImage::SizeType SizeType
Definition: itkConditionalConstIterator.h:54
itk::ShapedFloodFilledFunctionConditionalConstIterator::GetFunction
virtual SmartPointer< FunctionType > GetFunction() const
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:228
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itk::ShapedFloodFilledFunctionConditionalConstIterator::FunctionInputType
typename TFunction::InputType FunctionInputType
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:54
itk::ShapedFloodFilledFunctionConditionalConstIterator::m_FoundUncheckedNeighbor
bool m_FoundUncheckedNeighbor
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:287
itk::ConditionalConstIterator
A base class for other iterators where membership in the set of output pixels is conditional upon som...
Definition: itkConditionalConstIterator.h:38
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkConditionalConstIterator.h
itk::ShapedFloodFilledFunctionConditionalConstIterator::m_NeighborhoodIterator
NeighborhoodIteratorType m_NeighborhoodIterator
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:274
itk::ShapedFloodFilledFunctionConditionalConstIterator::m_Function
SmartPointer< FunctionType > m_Function
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:253
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itk::ShapedFloodFilledFunctionConditionalConstIterator::ClearSeeds
void ClearSeeds()
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:180
itk::ShapedFloodFilledFunctionConditionalConstIterator::m_LocationVector
FunctionInputType m_LocationVector
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:283
itk::ShapedFloodFilledFunctionConditionalConstIterator::m_IsValidIndex
bool m_IsValidIndex
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:290
itk::ShapedFloodFilledFunctionConditionalConstIterator::m_ImageSpacing
ImageType::SpacingType m_ImageSpacing
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:271
itk::ShapedFloodFilledFunctionConditionalConstIterator::Get
const PixelType Get() const override
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:159
itk::ConditionalConstIterator::PixelType
typename TImage::PixelType PixelType
Definition: itkConditionalConstIterator.h:66
itk::ShapedFloodFilledFunctionConditionalConstIterator::m_TempPtr
TTempImage::Pointer m_TempPtr
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:262
itkSize.h
itk::ShapedFloodFilledFunctionConditionalConstIterator::FunctionType
TFunction FunctionType
Definition: itkShapedFloodFilledFunctionConditionalConstIterator.h:51