18 #ifndef itkConstNeighborhoodIterator_h
19 #define itkConstNeighborhoodIterator_h
49 template<
typename TImage,
typename TBoundaryCondition =
52 public Neighborhood< typename TImage::InternalPixelType *,
53 TImage::ImageDimension >
64 itkStaticConstMacro(
Dimension, DimensionValueType, TImage::ImageDimension);
92 typedef typename ImageType::NeighborhoodAccessorFunctorType
116 const RegionType & region)
118 this->Initialize(radius, ptr, region);
119 for ( DimensionValueType i = 0; i <
Dimension; i++ )
120 { m_InBounds[i] =
false; }
121 this->ResetBoundaryCondition();
122 m_NeighborhoodAccessorFunctor = ptr->GetNeighborhoodAccessor();
123 m_NeighborhoodAccessorFunctor.SetBegin( ptr->GetBufferPointer() );
128 Self & operator=(
const Self & orig);
131 virtual void PrintSelf(std::ostream &,
Indent)
const;
135 OffsetType ComputeInternalIndex(
const NeighborIndexType n)
const;
144 {
return m_Bound[n]; }
148 {
return ( this->
operator[]( ( this->
Size() ) >> 1 ) ); }
153 {
return m_NeighborhoodAccessorFunctor.Get( this->GetCenterPointer() ); }
157 {
return m_ConstImage; }
165 {
return m_Loop + o; }
169 virtual NeighborhoodType GetNeighborhood()
const;
174 if ( !m_NeedToUseBoundaryCondition )
176 return ( m_NeighborhoodAccessorFunctor.Get( this->operator[](i) ) );
179 return this->GetPixel(i, inbounds);
188 virtual PixelType GetPixel(NeighborIndexType i,
bool & IsInBounds)
const;
196 return ( this->GetPixel(this->GetNeighborhoodIndex(o), inbounds) );
205 bool & IsInBounds)
const
206 {
return ( this->GetPixel(this->GetNeighborhoodIndex(o), IsInBounds) ); }
213 return ( this->GetPixel( this->GetCenterNeighborhoodIndex()
214 + ( i * this->GetStride(axis) ) ) );
222 return ( this->GetPixel( this->GetCenterNeighborhoodIndex()
223 + this->GetStride(axis) ) );
231 return ( this->GetPixel( this->GetCenterNeighborhoodIndex()
232 - ( i * this->GetStride(axis) ) ) );
240 return ( this->GetPixel( this->GetCenterNeighborhoodIndex()
241 - this->GetStride(axis) ) );
247 {
return ( this->GetIndex() + o ); }
252 {
return ( this->GetIndex() + this->GetOffset(i) ); }
261 {
return m_BeginIndex; }
265 RegionType GetBoundingBoxAsImageRegion()
const;
269 {
return m_WrapOffset; }
277 {
return m_WrapOffset[n]; }
282 virtual void GoToBegin();
286 virtual void GoToEnd();
290 virtual void Initialize(
const SizeType & radius,
const ImageType *ptr,
291 const RegionType & region);
296 {
return ( this->GetCenterPointer() == m_Begin ); }
302 if ( this->GetCenterPointer() > m_End )
305 std::ostringstream msg;
306 msg <<
"In method IsAtEnd, CenterPointer = " << this->GetCenterPointer()
307 <<
" is greater than End = " << m_End
313 return ( this->GetCenterPointer() == m_End );
371 this->SetLoop(position);
372 this->SetPixelPointers(position);
379 Self & operator+=(
const OffsetType &);
384 Self & operator-=(
const OffsetType &);
388 {
return m_Loop - b.
m_Loop; }
393 bool InBounds()
const;
406 bool IndexInBounds(
const NeighborIndexType n, OffsetType & internalIndex, OffsetType & offset )
const;
410 bool IndexInBounds(
const NeighborIndexType n )
const;
419 { m_BoundaryCondition = i; }
424 { m_BoundaryCondition = &m_InternalBoundaryCondition; }
428 { m_InternalBoundaryCondition = c; }
432 {
return m_BoundaryCondition; }
437 this->SetNeedToUseBoundaryCondition(
true);
442 this->SetNeedToUseBoundaryCondition(
false);
447 m_NeedToUseBoundaryCondition = b;
452 return m_NeedToUseBoundaryCondition;
456 virtual void SetRegion(
const RegionType & region);
463 { m_Loop = p; m_IsInBoundsValid =
false; }
468 virtual void SetBound(
const SizeType &);
474 virtual void SetPixelPointers(
const IndexType &);
479 { m_BeginIndex = start; }
483 virtual void SetEndIndex();
552 template<
typename TImage >
562 template<
typename TImage >
566 {
return ( it + ind ); }
568 template<
typename TImage >
580 #ifndef ITK_MANUAL_INSTANTIATION
581 #include "itkConstNeighborhoodIterator.hxx"
virtual IndexType GetIndex(void) const
virtual bool IsAtEnd() const
bool operator==(const Self &it) const
unsigned int DimensionValueType
OffsetValueType GetWrapOffset(NeighborIndexType n) const
NeighborhoodAccessorFunctorType m_NeighborhoodAccessorFunctor
bool GetNeedToUseBoundaryCondition() const
bool operator<=(const Self &it) const
ConstNeighborhoodIterator< TImage > operator-(const ConstNeighborhoodIterator< TImage > &it, const typename ConstNeighborhoodIterator< TImage >::OffsetType &ind)
virtual void SetDescription(const std::string &s)
TImage::PixelType PixelType
Represent the size (bounds) of a n-dimensional image.
Neighborhood< PixelType, itkGetStaticConstMacro(Dimension) > NeighborhoodType
bool operator!=(const Self &it) const
virtual PixelType GetNext(const unsigned axis) const
signed long OffsetValueType
virtual PixelType GetPixel(NeighborIndexType i) const
void NeedToUseBoundaryConditionOn()
IndexType m_InnerBoundsLow
virtual void OverrideBoundaryCondition(const ImageBoundaryConditionPointerType i)
A light-weight container object for storing an N-dimensional neighborhood of values.
signed long IndexValueType
IndexType GetBound() const
NeighborhoodType::NeighborIndexType NeighborIndexType
TBoundaryCondition m_InternalBoundaryCondition
virtual bool IsAtBegin() const
ConstNeighborhoodIterator Self
Superclass::RadiusType RadiusType
IndexType GetBeginIndex() const
virtual PixelType GetPixel(const OffsetType &o, bool &IsInBounds) const
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
virtual PixelType GetPrevious(const unsigned axis, NeighborIndexType i) const
virtual void ResetBoundaryCondition()
OffsetType GetWrapOffset() const
IndexType GetFastIndexPlusOffset(const OffsetType &o) const
ImageBoundaryCondition< ImageType > * ImageBoundaryConditionPointerType
Superclass::Iterator Iterator
IndexValueType GetBound(NeighborIndexType n) const
virtual PixelType GetNext(const unsigned axis, NeighborIndexType i) const
const InternalPixelType * m_End
ConstNeighborhoodIterator(const SizeType &radius, const ImageType *ptr, const RegionType ®ion)
Superclass::SizeType SizeType
const InternalPixelType * m_Begin
ImageType::ConstWeakPointer m_ConstImage
Superclass::ConstIterator ConstIterator
TBoundaryCondition BoundaryConditionType
ImageBoundaryConditionPointerType m_BoundaryCondition
void SetLocation(const IndexType &position)
ConstNeighborhoodIterator< TImage > operator+(const ConstNeighborhoodIterator< TImage > &it, const typename ConstNeighborhoodIterator< TImage >::OffsetType &ind)
PixelType GetCenterPixel() const
virtual IndexType GetIndex(const OffsetType &o) const
Standard exception handling object.
const unsigned int Dimension
Neighborhood< InternalPixelType *, itkGetStaticConstMacro(Dimension) > Superclass
virtual void SetLoop(const IndexType &p)
virtual void SetBeginIndex(const IndexType &start)
bool operator>=(const Self &it) const
TImage::RegionType RegionType
virtual PixelType GetPrevious(const unsigned axis) const
ImageType::NeighborhoodAccessorFunctorType NeighborhoodAccessorFunctorType
const ImageType * GetImagePointer(void) const
Index< itkGetStaticConstMacro(Dimension) > IndexType
RegionType GetRegion() const
AllocatorType::iterator Iterator
ImageBoundaryCondition< ImageType > const * ImageBoundaryConditionConstPointerType
const InternalPixelType * GetCenterPointer() const
bool m_NeedToUseBoundaryCondition
Control indentation during Print() invocation.
AllocatorType::const_iterator ConstIterator
bool operator<(const Self &it) const
ImageBaseType::SizeType SizeType
ImageBoundaryConditionPointerType GetBoundaryCondition() const
void SetBoundaryCondition(const TBoundaryCondition &c)
virtual IndexType GetIndex(NeighborIndexType i) const
void NeedToUseBoundaryConditionOff()
static ITK_CONSTEXPR_VAR double e
The base of the natural logarithm or Euler's number
void SetNeedToUseBoundaryCondition(bool b)
OffsetType operator-(const Self &b)
virtual ~ConstNeighborhoodIterator()
virtual PixelType GetPixel(const OffsetType &o) const
TImage::InternalPixelType InternalPixelType
ImageBaseType::IndexType IndexType
IndexType m_InnerBoundsHigh
bool operator>(const Self &it) const
Superclass::OffsetType OffsetType
SizeValueType NeighborIndexType