ITK  6.0.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
26namespace itk
27{
211template <typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
212class ITK_TEMPLATE_EXPORT NeighborhoodIterator : public ConstNeighborhoodIterator<TImage, TBoundaryCondition>
213{
214public:
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;
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
Pixel-wise addition of two images.
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
Defines iteration of a local N-dimensional neighborhood of pixels across an itk::Image.
ITK_ITERATOR_VIRTUAL void SetPrevious(const unsigned int axis, const unsigned int i, const PixelType &v) ITK_ITERATOR_FINAL
NeighborhoodIterator(const NeighborhoodIterator &n)
ITK_ITERATOR_VIRTUAL void SetNeighborhood(const NeighborhoodType &) ITK_ITERATOR_FINAL
ITK_ITERATOR_VIRTUAL void SetCenterPixel(const PixelType &p) ITK_ITERATOR_FINAL
ITK_ITERATOR_VIRTUAL void SetPrevious(const unsigned int axis, const PixelType &v) ITK_ITERATOR_FINAL
ITK_ITERATOR_VIRTUAL void SetPixel(const OffsetType o, const PixelType &v) ITK_ITERATOR_FINAL
ITK_ITERATOR_VIRTUAL void SetNext(const unsigned int axis, const unsigned int i, const PixelType &v) ITK_ITERATOR_FINAL
InternalPixelType * GetCenterPointer()
NeighborhoodIterator(const SizeType &radius, ImageType *ptr, const RegionType &region)
ITK_ITERATOR_VIRTUAL void SetPixel(const unsigned int i, const PixelType &v, bool &status) ITK_ITERATOR_FINAL
Self & operator=(const Self &orig)
ITK_ITERATOR_VIRTUAL void SetPixel(const unsigned int i, const PixelType &v) ITK_ITERATOR_FINAL
ITK_ITERATOR_VIRTUAL void SetNext(const unsigned int axis, const PixelType &v) ITK_ITERATOR_FINAL
A light-weight container object for storing an N-dimensional neighborhood of values.
typename AllocatorType::iterator Iterator
typename AllocatorType::const_iterator ConstIterator
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....