ITK  5.2.0
Insight Toolkit
itkNeighborhoodIterator.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 itkNeighborhoodIterator_h
19 #define itkNeighborhoodIterator_h
20 
21 #include <vector>
22 #include <cstring>
23 #include <iostream>
25 
26 namespace itk
27 {
211 template <typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
212 class ITK_TEMPLATE_EXPORT NeighborhoodIterator : public ConstNeighborhoodIterator<TImage, TBoundaryCondition>
213 {
214 public:
218 
220  using InternalPixelType = typename Superclass::InternalPixelType;
222  using SizeType = typename Superclass::SizeType;
223  using ImageType = typename Superclass::ImageType;
228  using NeighborhoodType = typename Superclass::NeighborhoodType;
229  using Iterator = typename Superclass::Iterator;
231  using ImageBoundaryConditionPointerType = typename Superclass::ImageBoundaryConditionPointerType;
232 
235  : Superclass()
236  {}
237 
240  : Superclass(n)
241  {}
242 
244  Self &
245  operator=(const Self & orig)
246  {
247  Superclass::operator=(orig);
248  return *this;
249  }
251 
254  NeighborhoodIterator(const SizeType & radius, ImageType * ptr, const RegionType & region)
255  : Superclass(radius, ptr, region)
256  {}
257 
259  void
260  PrintSelf(std::ostream &, Indent) const override;
261 
263  InternalPixelType *
265  {
266  return (this->operator[]((this->Size()) >> 1));
267  }
268 
270  ITK_ITERATOR_VIRTUAL void
271  SetCenterPixel(const PixelType & p) ITK_ITERATOR_FINAL
272  {
273  this->m_NeighborhoodAccessorFunctor.Set(this->operator[]((this->Size()) >> 1), p);
274  }
275 
279  ITK_ITERATOR_VIRTUAL void
280  SetNeighborhood(const NeighborhoodType &) ITK_ITERATOR_FINAL;
281 
284  ITK_ITERATOR_VIRTUAL void
285  SetPixel(const unsigned i, const PixelType & v, bool & status) ITK_ITERATOR_FINAL;
286 
288  ITK_ITERATOR_VIRTUAL void
289  SetPixel(const unsigned i, const PixelType & v) ITK_ITERATOR_FINAL;
290 
291  // { *(this->operator[](i)) = v; }
292 
294  ITK_ITERATOR_VIRTUAL void
295  SetPixel(const OffsetType o, const PixelType & v) ITK_ITERATOR_FINAL
296  {
297  this->SetPixel(this->GetNeighborhoodIndex(o), v);
298  }
299  // { *(this->operator[](o)) = v; }
301 
305  ITK_ITERATOR_VIRTUAL void
306  SetNext(const unsigned axis, const unsigned i, const PixelType & v) ITK_ITERATOR_FINAL
307  {
308  this->SetPixel(this->GetCenterNeighborhoodIndex() + (i * this->GetStride(axis)), v);
309  }
310 
314  ITK_ITERATOR_VIRTUAL void
315  SetNext(const unsigned axis, const PixelType & v) ITK_ITERATOR_FINAL
316  {
317  this->SetPixel(this->GetCenterNeighborhoodIndex() + this->GetStride(axis), v);
318  }
319 
323  ITK_ITERATOR_VIRTUAL void
324  SetPrevious(const unsigned axis, const unsigned i, const PixelType & v) ITK_ITERATOR_FINAL
325  {
326  this->SetPixel(this->GetCenterNeighborhoodIndex() - (i * this->GetStride(axis)), v);
327  }
328 
332  ITK_ITERATOR_VIRTUAL void
333  SetPrevious(const unsigned axis, const PixelType & v) ITK_ITERATOR_FINAL
334  {
335  this->SetPixel(this->GetCenterNeighborhoodIndex() - this->GetStride(axis), v);
336  }
337 };
338 } // namespace itk
340 
341 #ifndef ITK_MANUAL_INSTANTIATION
342 # include "itkNeighborhoodIterator.hxx"
343 #endif
344 
345 #endif
itk::NeighborhoodIterator::SetPrevious
ITK_ITERATOR_VIRTUAL void SetPrevious(const unsigned axis, const unsigned i, const PixelType &v) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:324
itk::NeighborhoodIterator::NeighborhoodIterator
NeighborhoodIterator()
Definition: itkNeighborhoodIterator.h:234
itk::Index< Self::Dimension >
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::RadiusType
typename Superclass::RadiusType RadiusType
Definition: itkConstNeighborhoodIterator.h:71
itkConstNeighborhoodIterator.h
itk::Size
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:69
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::PixelType
typename ImageType ::PixelType PixelType
Definition: itkConstNeighborhoodIterator.h:57
itk::NeighborhoodIterator::SetPrevious
ITK_ITERATOR_VIRTUAL void SetPrevious(const unsigned axis, const PixelType &v) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:333
itk::NeighborhoodIterator::SetNext
ITK_ITERATOR_VIRTUAL void SetNext(const unsigned axis, const unsigned i, const PixelType &v) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:306
itk::NeighborhoodIterator::NeighborhoodIterator
NeighborhoodIterator(const SizeType &radius, ImageType *ptr, const RegionType &region)
Definition: itkNeighborhoodIterator.h:254
itk::Neighborhood
A light-weight container object for storing an N-dimensional neighborhood of values.
Definition: itkNeighborhood.h:54
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::NeighborhoodIterator::operator=
Self & operator=(const Self &orig)
Definition: itkNeighborhoodIterator.h:245
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::ImageType
ImageType ImageType
Definition: itkConstNeighborhoodIterator.h:77
itk::ImageBoundaryCondition< ImageType, OutputImageType >
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::NeighborhoodIterator::NeighborhoodIterator
NeighborhoodIterator(const NeighborhoodIterator &n)
Definition: itkNeighborhoodIterator.h:239
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::InternalPixelType
typename ImageType ::InternalPixelType InternalPixelType
Definition: itkConstNeighborhoodIterator.h:56
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::Neighborhood::Iterator
typename AllocatorType::iterator Iterator
Definition: itkNeighborhood.h:75
itk::Neighborhood::PixelType
TPixel PixelType
Definition: itkNeighborhood.h:70
itk::Neighborhood::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:67
itk::NeighborhoodIterator
Defines iteration of a local N-dimensional neighborhood of pixels across an itk::Image.
Definition: itkNeighborhoodIterator.h:212
itk::NeighborhoodIterator::SetCenterPixel
ITK_ITERATOR_VIRTUAL void SetCenterPixel(const PixelType &p) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:271
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ConstNeighborhoodIterator
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
Definition: itkConstNeighborhoodIterator.h:51
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::RegionType
typename ImageType ::RegionType RegionType
Definition: itkConstNeighborhoodIterator.h:78
itk::NeighborhoodIterator::SetPixel
ITK_ITERATOR_VIRTUAL void SetPixel(const OffsetType o, const PixelType &v) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:295
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::ConstIterator
typename Superclass::ConstIterator ConstIterator
Definition: itkConstNeighborhoodIterator.h:74
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::OffsetType
typename Superclass::OffsetType OffsetType
Definition: itkConstNeighborhoodIterator.h:70
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::Iterator
typename Superclass::Iterator Iterator
Definition: itkConstNeighborhoodIterator.h:73
itk::NeighborhoodIterator::SetNext
ITK_ITERATOR_VIRTUAL void SetNext(const unsigned axis, const PixelType &v) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:315
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::SizeType
typename Superclass::SizeType SizeType
Definition: itkConstNeighborhoodIterator.h:72
itk::NeighborhoodIterator::GetCenterPointer
InternalPixelType * GetCenterPointer()
Definition: itkNeighborhoodIterator.h:264