ITK  5.1.0
Insight Toolkit
itkNeighborhoodIterator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 {
210 template <typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
211 class ITK_TEMPLATE_EXPORT NeighborhoodIterator : public ConstNeighborhoodIterator<TImage, TBoundaryCondition>
212 {
213 public:
217 
219  using InternalPixelType = typename Superclass::InternalPixelType;
221  using SizeType = typename Superclass::SizeType;
222  using ImageType = typename Superclass::ImageType;
227  using NeighborhoodType = typename Superclass::NeighborhoodType;
228  using Iterator = typename Superclass::Iterator;
230  using ImageBoundaryConditionPointerType = typename Superclass::ImageBoundaryConditionPointerType;
231 
234  : Superclass()
235  {}
236 
239  : Superclass(n)
240  {}
241 
243  Self &
244  operator=(const Self & orig)
245  {
246  Superclass::operator=(orig);
247  return *this;
248  }
250 
253  NeighborhoodIterator(const SizeType & radius, ImageType * ptr, const RegionType & region)
254  : Superclass(radius, ptr, region)
255  {}
256 
258  void
259  PrintSelf(std::ostream &, Indent) const;
260 
262  InternalPixelType *
264  {
265  return (this->operator[]((this->Size()) >> 1));
266  }
267 
269  ITK_ITERATOR_VIRTUAL void
270  SetCenterPixel(const PixelType & p) ITK_ITERATOR_FINAL
271  {
272  this->m_NeighborhoodAccessorFunctor.Set(this->operator[]((this->Size()) >> 1), p);
273  }
274 
278  ITK_ITERATOR_VIRTUAL void
279  SetNeighborhood(const NeighborhoodType &) ITK_ITERATOR_FINAL;
280 
283  ITK_ITERATOR_VIRTUAL void
284  SetPixel(const unsigned i, const PixelType & v, bool & status) ITK_ITERATOR_FINAL;
285 
287  ITK_ITERATOR_VIRTUAL void
288  SetPixel(const unsigned i, const PixelType & v) ITK_ITERATOR_FINAL;
289 
290  // { *(this->operator[](i)) = v; }
291 
293  ITK_ITERATOR_VIRTUAL void
294  SetPixel(const OffsetType o, const PixelType & v) ITK_ITERATOR_FINAL
295  {
296  this->SetPixel(this->GetNeighborhoodIndex(o), v);
297  }
298  // { *(this->operator[](o)) = v; }
300 
304  ITK_ITERATOR_VIRTUAL void
305  SetNext(const unsigned axis, const unsigned i, const PixelType & v) ITK_ITERATOR_FINAL
306  {
307  this->SetPixel(this->GetCenterNeighborhoodIndex() + (i * this->GetStride(axis)), v);
308  }
309 
313  ITK_ITERATOR_VIRTUAL void
314  SetNext(const unsigned axis, const PixelType & v) ITK_ITERATOR_FINAL
315  {
316  this->SetPixel(this->GetCenterNeighborhoodIndex() + this->GetStride(axis), v);
317  }
318 
322  ITK_ITERATOR_VIRTUAL void
323  SetPrevious(const unsigned axis, const unsigned i, const PixelType & v) ITK_ITERATOR_FINAL
324  {
325  this->SetPixel(this->GetCenterNeighborhoodIndex() - (i * this->GetStride(axis)), v);
326  }
327 
331  ITK_ITERATOR_VIRTUAL void
332  SetPrevious(const unsigned axis, const PixelType & v) ITK_ITERATOR_FINAL
333  {
334  this->SetPixel(this->GetCenterNeighborhoodIndex() - this->GetStride(axis), v);
335  }
336 };
337 } // namespace itk
339 
340 #ifndef ITK_MANUAL_INSTANTIATION
341 # include "itkNeighborhoodIterator.hxx"
342 #endif
343 
344 #endif
itk::NeighborhoodIterator::SetPrevious
ITK_ITERATOR_VIRTUAL void SetPrevious(const unsigned axis, const unsigned i, const PixelType &v) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:323
itk::NeighborhoodIterator::NeighborhoodIterator
NeighborhoodIterator()
Definition: itkNeighborhoodIterator.h:233
itk::Index< Self::Dimension >
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::RadiusType
typename Superclass::RadiusType RadiusType
Definition: itkConstNeighborhoodIterator.h:70
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:56
itk::NeighborhoodIterator::SetPrevious
ITK_ITERATOR_VIRTUAL void SetPrevious(const unsigned axis, const PixelType &v) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:332
itk::NeighborhoodIterator::SetNext
ITK_ITERATOR_VIRTUAL void SetNext(const unsigned axis, const unsigned i, const PixelType &v) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:305
itk::NeighborhoodIterator::NeighborhoodIterator
NeighborhoodIterator(const SizeType &radius, ImageType *ptr, const RegionType &region)
Definition: itkNeighborhoodIterator.h:253
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:244
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::ImageType
ImageType ImageType
Definition: itkConstNeighborhoodIterator.h:76
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:238
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::InternalPixelType
typename ImageType ::InternalPixelType InternalPixelType
Definition: itkConstNeighborhoodIterator.h:55
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:211
itk::NeighborhoodIterator::SetCenterPixel
ITK_ITERATOR_VIRTUAL void SetCenterPixel(const PixelType &p) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:270
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::ConstNeighborhoodIterator
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
Definition: itkConstNeighborhoodIterator.h:50
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::RegionType
typename ImageType ::RegionType RegionType
Definition: itkConstNeighborhoodIterator.h:77
itk::NeighborhoodIterator::SetPixel
ITK_ITERATOR_VIRTUAL void SetPixel(const OffsetType o, const PixelType &v) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:294
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::ConstIterator
typename Superclass::ConstIterator ConstIterator
Definition: itkConstNeighborhoodIterator.h:73
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::OffsetType
typename Superclass::OffsetType OffsetType
Definition: itkConstNeighborhoodIterator.h:69
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::Iterator
typename Superclass::Iterator Iterator
Definition: itkConstNeighborhoodIterator.h:72
itk::NeighborhoodIterator::SetNext
ITK_ITERATOR_VIRTUAL void SetNext(const unsigned axis, const PixelType &v) ITK_ITERATOR_FINAL
Definition: itkNeighborhoodIterator.h:314
itk::ConstNeighborhoodIterator< ImageType, ZeroFluxNeumannBoundaryCondition< ImageType > >::SizeType
typename Superclass::SizeType SizeType
Definition: itkConstNeighborhoodIterator.h:71
itk::NeighborhoodIterator::GetCenterPointer
InternalPixelType * GetCenterPointer()
Definition: itkNeighborhoodIterator.h:263