ITK  5.4.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  * 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 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 typename Superclass::InternalPixelType;
221  using typename Superclass::PixelType;
222  using typename Superclass::SizeType;
223  using typename Superclass::ImageType;
224  using typename Superclass::RegionType;
225  using typename Superclass::IndexType;
226  using typename Superclass::OffsetType;
227  using typename Superclass::RadiusType;
228  using typename Superclass::NeighborhoodType;
229  using typename Superclass::Iterator;
230  using typename Superclass::ConstIterator;
231  using 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  }
254  NeighborhoodIterator(const SizeType & radius, ImageType * ptr, const RegionType & region)
255  : Superclass(radius, ptr, region)
256  {}
257 
259  InternalPixelType *
261  {
262  return (this->operator[]((this->Size()) >> 1));
263  }
264 
266  ITK_ITERATOR_VIRTUAL void
267  SetCenterPixel(const PixelType & p) ITK_ITERATOR_FINAL
268  {
269  this->m_NeighborhoodAccessorFunctor.Set(this->operator[]((this->Size()) >> 1), p);
270  }
271 
275  ITK_ITERATOR_VIRTUAL void
276  SetNeighborhood(const NeighborhoodType &) ITK_ITERATOR_FINAL;
277 
280  ITK_ITERATOR_VIRTUAL void
281  SetPixel(const unsigned int i, const PixelType & v, bool & status) ITK_ITERATOR_FINAL;
282 
284  ITK_ITERATOR_VIRTUAL void
285  SetPixel(const unsigned int i, const PixelType & v) ITK_ITERATOR_FINAL;
286 
287  // { *(this->operator[](i)) = v; }
288 
290  ITK_ITERATOR_VIRTUAL void
291  SetPixel(const OffsetType o, const PixelType & v) ITK_ITERATOR_FINAL
292  {
293  this->SetPixel(this->GetNeighborhoodIndex(o), v);
294  }
295  // { *(this->operator[](o)) = v; }
301  ITK_ITERATOR_VIRTUAL void
302  SetNext(const unsigned int axis, const unsigned int i, const PixelType & v) ITK_ITERATOR_FINAL
303  {
304  this->SetPixel(this->GetCenterNeighborhoodIndex() + (i * this->GetStride(axis)), v);
305  }
306 
310  ITK_ITERATOR_VIRTUAL void
311  SetNext(const unsigned int axis, const PixelType & v) ITK_ITERATOR_FINAL
312  {
313  this->SetPixel(this->GetCenterNeighborhoodIndex() + this->GetStride(axis), v);
314  }
315 
319  ITK_ITERATOR_VIRTUAL void
320  SetPrevious(const unsigned int axis, const unsigned int i, const PixelType & v) ITK_ITERATOR_FINAL
321  {
322  this->SetPixel(this->GetCenterNeighborhoodIndex() - (i * this->GetStride(axis)), v);
323  }
324 
328  ITK_ITERATOR_VIRTUAL void
329  SetPrevious(const unsigned int axis, const PixelType & v) ITK_ITERATOR_FINAL
330  {
331  this->SetPixel(this->GetCenterNeighborhoodIndex() - this->GetStride(axis), v);
332  }
333 };
334 } // namespace itk
337 #ifndef ITK_MANUAL_INSTANTIATION
338 # include "itkNeighborhoodIterator.hxx"
339 #endif
340 
341 #endif
itk::NeighborhoodIterator::NeighborhoodIterator
NeighborhoodIterator()
Definition: itkNeighborhoodIterator.h:234
itkConstNeighborhoodIterator.h
itk::Size
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:71
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::PixelType
typename ImageType ::PixelType PixelType
Definition: itkConstNeighborhoodIterator.h:57
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::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::ImageType
ImageType ImageType
Definition: itkConstNeighborhoodIterator.h:77
itk::NeighborhoodIterator::SetNext
ITK_ITERATOR_VIRTUAL void SetNext(const unsigned int axis, const PixelType &v) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:311
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::NeighborhoodIterator::NeighborhoodIterator
NeighborhoodIterator(const NeighborhoodIterator &n)
Definition: itkNeighborhoodIterator.h:239
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::Neighborhood::Iterator
typename AllocatorType::iterator Iterator
Definition: itkNeighborhood.h:75
itk::NeighborhoodIterator::SetPrevious
ITK_ITERATOR_VIRTUAL void SetPrevious(const unsigned int axis, const PixelType &v) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:329
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:69
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:267
itk::NeighborhoodIterator::SetPrevious
ITK_ITERATOR_VIRTUAL void SetPrevious(const unsigned int axis, const unsigned int i, const PixelType &v) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:320
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:291
AddImageFilter
Definition: itkAddImageFilter.h:81
itk::NeighborhoodIterator::SetNext
ITK_ITERATOR_VIRTUAL void SetNext(const unsigned int axis, const unsigned int i, const PixelType &v) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:302
itk::NeighborhoodIterator::GetCenterPointer
InternalPixelType * GetCenterPointer()
Definition: itkNeighborhoodIterator.h:260