ITK  5.0.0
Insight Segmentation and Registration 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 =
212 class ITK_TEMPLATE_EXPORT NeighborhoodIterator:
213  public ConstNeighborhoodIterator< TImage, TBoundaryCondition >
214 {
215 public:
219 
221  using InternalPixelType = typename Superclass::InternalPixelType;
223  using SizeType = typename Superclass::SizeType;
224  using ImageType = typename Superclass::ImageType;
229  using NeighborhoodType = typename Superclass::NeighborhoodType;
230  using Iterator = typename Superclass::Iterator;
232  using ImageBoundaryConditionPointerType = typename Superclass::ImageBoundaryConditionPointerType;
233 
236 
239 
241  Self & operator=(const Self & orig)
242  {
243  Superclass::operator=(orig);
244  return *this;
245  }
247 
251  const RegionType & region):
252  Superclass(radius, ptr, region) {}
253 
255  void PrintSelf(std::ostream &, Indent) const;
256 
259  { return ( this->operator[]( ( this->Size() ) >> 1 ) ); }
260 
262  ITK_ITERATOR_VIRTUAL void SetCenterPixel(const PixelType & p) ITK_ITERATOR_FINAL
263  { this->m_NeighborhoodAccessorFunctor.Set(this->operator[]( ( this->Size() ) >> 1 ), p); }
264 
268  ITK_ITERATOR_VIRTUAL void SetNeighborhood(const NeighborhoodType &) ITK_ITERATOR_FINAL;
269 
272  ITK_ITERATOR_VIRTUAL void SetPixel(const unsigned i, const PixelType & v,
273  bool & status) ITK_ITERATOR_FINAL;
274 
276  ITK_ITERATOR_VIRTUAL void SetPixel(const unsigned i, const PixelType & v) ITK_ITERATOR_FINAL;
277 
278  // { *(this->operator[](i)) = v; }
279 
281  ITK_ITERATOR_VIRTUAL void SetPixel(const OffsetType o, const PixelType & v) ITK_ITERATOR_FINAL
282  { this->SetPixel(this->GetNeighborhoodIndex(o), v); }
283  // { *(this->operator[](o)) = v; }
285 
289  ITK_ITERATOR_VIRTUAL void SetNext(const unsigned axis, const unsigned i,
290  const PixelType & v) ITK_ITERATOR_FINAL
291  {
292  this->SetPixel(this->GetCenterNeighborhoodIndex()
293  + ( i * this->GetStride(axis) ), v);
294  }
295 
299  ITK_ITERATOR_VIRTUAL void SetNext(const unsigned axis, const PixelType & v) ITK_ITERATOR_FINAL
300  {
301  this->SetPixel(this->GetCenterNeighborhoodIndex()
302  + this->GetStride(axis), v);
303  }
304 
308  ITK_ITERATOR_VIRTUAL void SetPrevious(const unsigned axis, const unsigned i,
309  const PixelType & v) ITK_ITERATOR_FINAL
310  {
311  this->SetPixel(this->GetCenterNeighborhoodIndex()
312  - ( i * this->GetStride(axis) ), v);
313  }
314 
318  ITK_ITERATOR_VIRTUAL void SetPrevious(const unsigned axis,
319  const PixelType & v) ITK_ITERATOR_FINAL
320  {
321  this->SetPixel(this->GetCenterNeighborhoodIndex()
322  - this->GetStride(axis), v);
323  }
324 };
325 } // namespace itk
327 
328 #ifndef ITK_MANUAL_INSTANTIATION
329 #include "itkNeighborhoodIterator.hxx"
330 #endif
331 
332 #endif
A light-weight container object for storing an N-dimensional neighborhood of values.
typename AllocatorType::iterator Iterator
NeighborhoodIterator(const SizeType &radius, ImageType *ptr, const RegionType &region)
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
ITK_ITERATOR_VIRTUAL void SetCenterPixel(const PixelType &p) ITK_ITERATOR_FINAL
typename AllocatorType::const_iterator ConstIterator
NeighborhoodIterator(const NeighborhoodIterator &n)
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:68
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image...
Definition: itkOffset.h:67
ITK_ITERATOR_VIRTUAL void SetNext(const unsigned axis, const PixelType &v) ITK_ITERATOR_FINAL
Self & operator=(const Self &orig)
InternalPixelType * GetCenterPointer()
Control indentation during Print() invocation.
Definition: itkIndent.h:49
ITK_ITERATOR_VIRTUAL void SetNext(const unsigned axis, const unsigned i, const PixelType &v) ITK_ITERATOR_FINAL
ITK_ITERATOR_VIRTUAL void SetPrevious(const unsigned axis, const unsigned i, const PixelType &v) ITK_ITERATOR_FINAL
ITK_ITERATOR_VIRTUAL void SetPrevious(const unsigned axis, const PixelType &v) ITK_ITERATOR_FINAL
Defines iteration of a local N-dimensional neighborhood of pixels across an itk::Image.