18 #ifndef itkConstNeighborhoodIterator_h
19 #define itkConstNeighborhoodIterator_h
49 template<
typename TImage,
typename TBoundaryCondition =
52 public Neighborhood< typename TImage::InternalPixelType *,
53 TImage::ImageDimension >
57 using InternalPixelType =
typename TImage::InternalPixelType;
61 using DimensionValueType =
unsigned int;
64 static constexpr DimensionValueType
Dimension = TImage::ImageDimension;
117 this->Initialize(radius, ptr, region);
118 for ( DimensionValueType i = 0; i <
Dimension; i++ )
119 { m_InBounds[i] =
false; }
120 this->ResetBoundaryCondition();
121 m_NeighborhoodAccessorFunctor = ptr->GetNeighborhoodAccessor();
122 m_NeighborhoodAccessorFunctor.SetBegin( ptr->GetBufferPointer() );
127 Self & operator=(
const Self & orig);
130 void PrintSelf(std::ostream &,
Indent)
const override;
134 OffsetType ComputeInternalIndex(
const NeighborIndexType n)
const;
143 {
return m_Bound[n]; }
147 {
return ( this->
operator[]( ( this->
Size() ) >> 1 ) ); }
152 {
return m_NeighborhoodAccessorFunctor.Get( this->GetCenterPointer() ); }
156 {
return m_ConstImage; }
164 {
return m_Loop + o; }
168 ITK_ITERATOR_VIRTUAL NeighborhoodType GetNeighborhood() const ITK_ITERATOR_FINAL;
173 if ( !m_NeedToUseBoundaryCondition || this->InBounds() )
175 return ( m_NeighborhoodAccessorFunctor.Get( this->operator[](i) ) );
181 return this->IndexInBounds(i, internalIndex, offset) ?
182 m_NeighborhoodAccessorFunctor.Get(this->
operator[](i)) :
183 m_NeighborhoodAccessorFunctor.BoundaryCondition(internalIndex, offset,
this, m_BoundaryCondition);
191 ITK_ITERATOR_VIRTUAL PixelType GetPixel(NeighborIndexType i,
bool & IsInBounds)
const ITK_ITERATOR_FINAL;
199 return ( this->GetPixel(this->GetNeighborhoodIndex(o), inbounds) );
208 bool & IsInBounds)
const ITK_ITERATOR_FINAL
209 {
return ( this->GetPixel(this->GetNeighborhoodIndex(o), IsInBounds) ); }
216 return ( this->GetPixel( this->GetCenterNeighborhoodIndex()
217 + ( i * this->GetStride(axis) ) ) );
225 return ( this->GetPixel( this->GetCenterNeighborhoodIndex()
226 + this->GetStride(axis) ) );
234 return ( this->GetPixel( this->GetCenterNeighborhoodIndex()
235 - ( i * this->GetStride(axis) ) ) );
243 return ( this->GetPixel( this->GetCenterNeighborhoodIndex()
244 - this->GetStride(axis) ) );
250 {
return ( this->GetIndex() + o ); }
255 {
return ( this->GetIndex() + this->GetOffset(i) ); }
264 {
return m_BeginIndex; }
268 RegionType GetBoundingBoxAsImageRegion()
const;
272 {
return m_WrapOffset; }
280 {
return m_WrapOffset[n]; }
283 ITK_ITERATOR_VIRTUAL
void GoToBegin() ITK_ITERATOR_FINAL;
287 ITK_ITERATOR_VIRTUAL
void GoToEnd() ITK_ITERATOR_FINAL;
291 ITK_ITERATOR_VIRTUAL
void Initialize(const
SizeType & radius, const ImageType *ptr,
292 const
RegionType & region) ITK_ITERATOR_FINAL;
296 ITK_ITERATOR_VIRTUAL
bool IsAtBegin() const ITK_ITERATOR_FINAL
297 {
return ( this->GetCenterPointer() == m_Begin ); }
301 ITK_ITERATOR_VIRTUAL
bool IsAtEnd() const ITK_ITERATOR_FINAL
303 if ( this->GetCenterPointer() > m_End )
306 std::ostringstream msg;
307 msg <<
"In method IsAtEnd, CenterPointer = " << this->GetCenterPointer()
308 <<
" is greater than End = " << m_End
314 return ( this->GetCenterPointer() == m_End );
372 this->SetLoop(position);
373 this->SetPixelPointers(position);
380 Self & operator+=(
const OffsetType &);
385 Self & operator-=(
const OffsetType &);
389 {
return m_Loop - b.
m_Loop; }
394 bool InBounds()
const;
407 bool IndexInBounds(
const NeighborIndexType n, OffsetType & internalIndex, OffsetType & offset )
const;
411 bool IndexInBounds(
const NeighborIndexType n )
const;
420 { m_BoundaryCondition = i; }
425 { m_BoundaryCondition = &m_InternalBoundaryCondition; }
429 { m_InternalBoundaryCondition = c; }
433 {
return m_BoundaryCondition; }
438 this->SetNeedToUseBoundaryCondition(
true);
443 this->SetNeedToUseBoundaryCondition(
false);
448 m_NeedToUseBoundaryCondition = b;
453 return m_NeedToUseBoundaryCondition;
457 ITK_ITERATOR_VIRTUAL
void SetRegion(
const RegionType & region) ITK_ITERATOR_FINAL;
464 { m_Loop = p; m_IsInBoundsValid =
false; }
469 ITK_ITERATOR_VIRTUAL
void SetBound(
const SizeType &) ITK_ITERATOR_FINAL;
475 ITK_ITERATOR_VIRTUAL
void SetPixelPointers(const
IndexType &) ITK_ITERATOR_FINAL;
479 ITK_ITERATOR_VIRTUAL
void SetBeginIndex(const
IndexType & start) ITK_ITERATOR_FINAL
480 { m_BeginIndex = start; }
484 ITK_ITERATOR_VIRTUAL
void SetEndIndex() ITK_ITERATOR_FINAL;
494 const InternalPixelType *m_Begin;
500 const InternalPixelType *m_End;
530 mutable
bool m_IsInBounds{
false};
535 mutable bool m_IsInBoundsValid{
false};
547 bool m_NeedToUseBoundaryCondition{
false};
553 template<
typename TImage >
563 template<
typename TImage >
567 {
return ( it + ind ); }
569 template<
typename TImage >
581 #ifndef ITK_MANUAL_INSTANTIATION
582 #include "itkConstNeighborhoodIterator.hxx"
typename NeighborhoodType::NeighborIndexType NeighborIndexType
bool operator==(const Self &it) const
ITK_ITERATOR_VIRTUAL bool IsAtEnd() const ITK_ITERATOR_FINAL
typename Superclass::OffsetType OffsetType
OffsetValueType GetWrapOffset(NeighborIndexType n) const
NeighborhoodAccessorFunctorType m_NeighborhoodAccessorFunctor
bool GetNeedToUseBoundaryCondition() const
bool operator<=(const Self &it) const
ITK_ITERATOR_VIRTUAL PixelType GetPrevious(const unsigned axis) const ITK_ITERATOR_FINAL
ConstNeighborhoodIterator< TImage > operator-(const ConstNeighborhoodIterator< TImage > &it, const typename ConstNeighborhoodIterator< TImage >::OffsetType &ind)
virtual void SetDescription(const std::string &s)
ITK_ITERATOR_VIRTUAL void SetLoop(const IndexType &p) ITK_ITERATOR_FINAL
bool operator!=(const Self &it) const
void NeedToUseBoundaryConditionOn()
IndexType m_InnerBoundsLow
ITK_ITERATOR_VIRTUAL PixelType GetNext(const unsigned axis) const ITK_ITERATOR_FINAL
A light-weight container object for storing an N-dimensional neighborhood of values.
IndexType GetBound() const
SizeValueType NeighborIndexType
typename AllocatorType::iterator Iterator
TBoundaryCondition m_InternalBoundaryCondition
typename BoundaryConditionType::OutputImageType OutputImageType
TSparseImageType ImageType
IndexType GetBeginIndex() const
ITK_ITERATOR_VIRTUAL IndexType GetIndex(NeighborIndexType i) const ITK_ITERATOR_FINAL
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
typename TSparseImageType::PixelType PixelType
constexpr unsigned int Dimension
ITK_ITERATOR_VIRTUAL void ResetBoundaryCondition() ITK_ITERATOR_FINAL
OffsetType GetWrapOffset() const
IndexType GetFastIndexPlusOffset(const OffsetType &o) const
typename AllocatorType::const_iterator ConstIterator
IndexValueType GetBound(NeighborIndexType n) const
ITK_ITERATOR_VIRTUAL PixelType GetPrevious(const unsigned axis, NeighborIndexType i) const ITK_ITERATOR_FINAL
typename Superclass::SizeType SizeType
ConstNeighborhoodIterator(const SizeType &radius, const ImageType *ptr, const RegionType ®ion)
ITK_ITERATOR_VIRTUAL PixelType GetPixel(const OffsetType &o) const ITK_ITERATOR_FINAL
TSparseImageType OutputImageType
const ImageType * GetImagePointer() const
void SetLocation(const IndexType &position)
ImageBaseType::SizeType SizeType
ConstNeighborhoodIterator< TImage > operator+(const ConstNeighborhoodIterator< TImage > &it, const typename ConstNeighborhoodIterator< TImage >::OffsetType &ind)
PixelType GetCenterPixel() const
ImageBaseType::IndexType IndexType
signed long IndexValueType
Represent a n-dimensional size (bounds) of a n-dimensional image.
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image...
typename ImageType::NeighborhoodAccessorFunctorType NeighborhoodAccessorFunctorType
Standard exception handling object.
typename Superclass::ConstIterator ConstIterator
bool operator>=(const Self &it) const
typename Superclass::Iterator Iterator
RegionType GetRegion() const
static constexpr double e
The base of the natural logarithm or Euler's number
const InternalPixelType * GetCenterPointer() const
ITK_ITERATOR_VIRTUAL PixelType GetNext(const unsigned axis, NeighborIndexType i) const ITK_ITERATOR_FINAL
Control indentation during Print() invocation.
bool operator<(const Self &it) const
typename Superclass::RadiusType RadiusType
ImageBoundaryConditionPointerType GetBoundaryCondition() const
void SetBoundaryCondition(const TBoundaryCondition &c)
ITK_ITERATOR_VIRTUAL IndexType GetIndex(const OffsetType &o) const ITK_ITERATOR_FINAL
ImageBaseType::RegionType RegionType
ITK_ITERATOR_VIRTUAL PixelType GetPixel(const OffsetType &o, bool &IsInBounds) const ITK_ITERATOR_FINAL
void NeedToUseBoundaryConditionOff()
ITK_ITERATOR_VIRTUAL void OverrideBoundaryCondition(const ImageBoundaryConditionPointerType i) ITK_ITERATOR_FINAL
void SetNeedToUseBoundaryCondition(bool b)
OffsetType operator-(const Self &b)
signed long OffsetValueType
IndexType m_InnerBoundsHigh
ITK_ITERATOR_VIRTUAL IndexType GetIndex() const ITK_ITERATOR_FINAL
bool operator>(const Self &it) const