ITK  5.1.0
Insight Toolkit
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition > Class Template Reference

#include <itkShapedNeighborhoodIterator.h>

+ Inheritance diagram for itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >:
+ Collaboration diagram for itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >:

Classes

struct  Iterator
 

Public Types

using BoundaryConditionType = typename Superclass::BoundaryConditionType
 
using ConstIterator = typename Superclass::ConstIterator
 
using ImageBoundaryConditionPointerType = typename Superclass::ImageBoundaryConditionPointerType
 
using ImageType = typename Superclass::ImageType
 
using IndexListType = typename Superclass::IndexListType
 
using IndexType = typename Superclass::IndexType
 
using IndexValueType = typename Superclass::IndexValueType
 
using InternalPixelType = typename TImage::InternalPixelType
 
using NeighborhoodType = typename Superclass::NeighborhoodType
 
using OffsetType = typename Superclass::OffsetType
 
using OffsetValueType = typename OffsetType::OffsetValueType
 
using PixelType = typename TImage::PixelType
 
using RadiusType = typename Superclass::RadiusType
 
using RegionType = typename Superclass::RegionType
 
using Self = ShapedNeighborhoodIterator
 
using SizeType = typename Superclass::SizeType
 
using SizeValueType = typename Superclass::SizeValueType
 
using Superclass = ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >
 
- Public Types inherited from itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >
using BoundaryConditionType = TBoundaryCondition
 
using ImageBoundaryConditionPointerType = ImageBoundaryCondition< ImageType > *
 
using ImageType = TImage
 
using IndexListConstIterator = typename IndexListType::const_iterator
 
using IndexListIterator = typename IndexListType::iterator
 
using IndexListType = std::list< NeighborIndexType >
 
using IndexType = Index< Self::Dimension >
 
using IndexValueType = typename IndexType::IndexValueType
 
using InternalPixelType = typename TImage::InternalPixelType
 
using NeighborhoodType = Neighborhood< PixelType, Self::Dimension >
 
using NeighborIndexType = typename NeighborhoodType::NeighborIndexType
 
using OffsetType = typename Superclass::OffsetType
 
using OffsetValueType = typename OffsetType::OffsetValueType
 
using PixelType = typename TImage::PixelType
 
using RadiusType = typename Superclass::RadiusType
 
using RegionType = typename TImage::RegionType
 
using Self = ConstShapedNeighborhoodIterator
 
using SizeType = typename Superclass::SizeType
 
using SizeValueType = typename SizeType::SizeValueType
 
using Superclass = NeighborhoodIterator< TImage, TBoundaryCondition >
 

Public Member Functions

 ShapedNeighborhoodIterator ()=default
 
 ShapedNeighborhoodIterator (const SizeType &radius, const ImageType *ptr, const RegionType &region)
 
 ~ShapedNeighborhoodIterator () override=default
 
- Public Member Functions inherited from itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >
ConstIterator Begin () const
 
ConstIterator End () const
 
 ConstShapedNeighborhoodIterator ()=default
 
 ~ConstShapedNeighborhoodIterator () override=default
 
 ConstShapedNeighborhoodIterator (const SizeType &radius, const ImageType *ptr, const RegionType &region)
 
Selfoperator= (const Self &orig)
 
ITK_ITERATOR_VIRTUAL void ActivateOffset (const OffsetType &off) ITK_ITERATOR_FINAL
 
ITK_ITERATOR_VIRTUAL void DeactivateOffset (const OffsetType &off) ITK_ITERATOR_FINAL
 
template<typename TOffsets >
void ActivateOffsets (const TOffsets &offsets)
 
ITK_ITERATOR_VIRTUAL void ClearActiveList () ITK_ITERATOR_FINAL
 
const IndexListTypeGetActiveIndexList () const
 
IndexListType::size_type GetActiveIndexListSize () const
 
void CreateActiveListFromNeighborhood (const NeighborhoodType &)
 
Selfoperator++ ()
 
Selfoperator-- ()
 
Selfoperator+= (const OffsetType &)
 
Selfoperator-= (const OffsetType &)
 
const SizeType GetRadius () const
 
SizeValueType GetRadius (DimensionValueType n) const
 
virtual NeighborIndexType GetNeighborhoodIndex (const OffsetType &) const
 
NeighborIndexType GetCenterNeighborhoodIndex () const
 
OffsetType GetOffset (NeighborIndexType i) const
 
bool operator== (const Self &other) const
 
bool operator!= (const Self &other) const
 
TPixel & GetElement (NeighborIndexType i)
 
void Print (std::ostream &os) const
 

Static Public Attributes

static constexpr unsigned int Dimension = TImage::ImageDimension
 
- Static Public Attributes inherited from itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >
static constexpr unsigned int Dimension = TImage::ImageDimension
 
using NeighborIndexType = typename Superclass::NeighborIndexType
 
friend Superclass
 
Selfoperator= (const Self &orig)
 
void PrintSelf (std::ostream &, Indent) const override
 
Iterator Begin ()
 
Iterator End ()
 
Iterator Begin ()
 
ConstIterator Begin () const
 
Iterator End ()
 
ConstIterator End () const
 
 ShapedNeighborhoodIterator (const ShapedNeighborhoodIterator &o)=delete
 

Additional Inherited Members

- Protected Member Functions inherited from itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >
ITK_ITERATOR_VIRTUAL void ActivateIndex (NeighborIndexType) ITK_ITERATOR_FINAL
 
ITK_ITERATOR_VIRTUAL void DeactivateIndex (NeighborIndexType) ITK_ITERATOR_FINAL
 
- Protected Attributes inherited from itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >
bool m_CenterIsActive { false }
 
IndexListType m_ActiveIndexList
 

Detailed Description

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
class itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >

A neighborhood iterator which can take on an arbitrary shape.

General Information
The ShapedNeighborhoodIterator is a refinement of NeighborhoodIterator which allows the user to specify which of the neighborhood elements are active and which will be ignored. This is useful for applications which only need to work with a subset of the neighborhood around a pixel such as morphological operations or cellular automata. This iterator can also be used, for example, to specify "cross-shaped" neighborhood where only elements along a spatial axes are significant.
Constructing a shaped neighborhood iterator
A shaped neighborhood iterator is constructed by constructing a list of active neighbor locations. The list is called the ActiveIndexList. The methods ActivateOffset, DeactivateOffset, and ClearActiveList are used to construct the ActiveIndexList. The argument to Activate/DeactivateOffset is an itk::Offset which represents the ND spatial offset from the center of the neighborhood. For example, to activate the center pixel in the neighborhood, you would do the following:
using ImageType = Image<float, 3>;
ShapedNeighborhoodIterator<ImageType> it(radius, image, region);
it.ActivateOffset(offset);

where radius, image, and region are as described in NeighborhoodIterator.

Once a neighborhood location has been activated, iteration (operator++, operator--, operator+=, operator-=) will update the value at the active location. Note that values at inactive locations will NOT be valid if queried.

Accessing elements in a shaped neighborhood.
To access the value at an active neighborhood location, you can use the standard GetPixel, SetPixel methods. SetPixel is not defined for ConstShapedNeighborhoodIterator. The class will not complain if you attempt to access a value at a non-active location, but be aware that the result will be undefined. Error checking is not done in this case for the sake of efficiency.

A second way to access active shaped neighborhood values is through a ShapedNeighborhoodIterator::Iterator or ConstShapedNeighborhoodIterator::ConstIterator. The following example demonstrates the use of these iterators.

using ImageType = Image<float, 3>;
ShapedNeighborhoodIterator<ImageType> it(radius, image, region);
.
.
.
it.ActivateOffset(offset1);
it.ActivateOffset(offset2);
it.ActivateOffset(offset3);
etc..
.
.
.
ShapedNeighborhoodIterator<ImageType>::Iterator i;
for (i = it.Begin(); ! i.IsAtEnd(); i++)
{ i.Set(i.Get() + 1.0); }
\\ you may also use i != i.End(), but IsAtEnd() may be slightly faster.

You can also iterate backward through the neighborhood active list.

i = it.End();
i--;
while (i != it.Begin())
{
i.Set(i.Get() + 1.0);
i--;
}
i.Set(i.Get() + 1.0);

The Get() Set() syntax was chosen versus defining operator* for these iterators because lvalue vs. rvalue context information is needed to determine whether bounds checking must take place.

See also
Neighborhood
MORE INFORMATION
For a complete description of the ITK Image Iterators and their API, please see the Iterators chapter in the ITK Software Guide. The ITK Software Guide is available in print and as a free .pdf download from https://www.itk.org.
See also
ImageConstIterator
ConditionalConstIterator
ConstNeighborhoodIterator
ConstShapedNeighborhoodIterator
ConstSliceIterator
CorrespondenceDataStructureIterator
FloodFilledFunctionConditionalConstIterator
FloodFilledImageFunctionConditionalConstIterator
FloodFilledImageFunctionConditionalIterator
FloodFilledSpatialFunctionConditionalConstIterator
FloodFilledSpatialFunctionConditionalIterator
ImageConstIterator
ImageConstIteratorWithIndex
ImageIterator
ImageIteratorWithIndex
ImageLinearConstIteratorWithIndex
ImageLinearIteratorWithIndex
ImageRandomConstIteratorWithIndex
ImageRandomIteratorWithIndex
ImageRegionConstIterator
ImageRegionConstIteratorWithIndex
ImageRegionExclusionConstIteratorWithIndex
ImageRegionExclusionIteratorWithIndex
ImageRegionIterator
ImageRegionIteratorWithIndex
ImageRegionReverseConstIterator
ImageRegionReverseIterator
ImageReverseConstIterator
ImageReverseIterator
ImageSliceConstIteratorWithIndex
ImageSliceIteratorWithIndex
NeighborhoodIterator
PathConstIterator
PathIterator
ShapedNeighborhoodIterator
SliceIterator
ImageConstIteratorWithIndex
ITK Sphinx Examples:
\li All ITK Sphinx Examples

Definition at line 153 of file itkShapedNeighborhoodIterator.h.

Member Typedef Documentation

◆ BoundaryConditionType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::BoundaryConditionType = typename Superclass::BoundaryConditionType

Definition at line 176 of file itkShapedNeighborhoodIterator.h.

◆ ConstIterator

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::ConstIterator = typename Superclass::ConstIterator

Definition at line 174 of file itkShapedNeighborhoodIterator.h.

◆ ImageBoundaryConditionPointerType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::ImageBoundaryConditionPointerType = typename Superclass::ImageBoundaryConditionPointerType

Definition at line 177 of file itkShapedNeighborhoodIterator.h.

◆ ImageType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::ImageType = typename Superclass::ImageType

Definition at line 180 of file itkShapedNeighborhoodIterator.h.

◆ IndexListType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::IndexListType = typename Superclass::IndexListType

Definition at line 175 of file itkShapedNeighborhoodIterator.h.

◆ IndexType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::IndexType = typename Superclass::IndexType

Definition at line 179 of file itkShapedNeighborhoodIterator.h.

◆ IndexValueType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::IndexValueType = typename Superclass::IndexValueType

Definition at line 182 of file itkShapedNeighborhoodIterator.h.

◆ InternalPixelType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::InternalPixelType = typename TImage::InternalPixelType

Extract image type information.

Definition at line 158 of file itkShapedNeighborhoodIterator.h.

◆ NeighborhoodType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::NeighborhoodType = typename Superclass::NeighborhoodType

Definition at line 178 of file itkShapedNeighborhoodIterator.h.

◆ NeighborIndexType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::NeighborIndexType = typename Superclass::NeighborIndexType
protected

Assignment operator

Definition at line 269 of file itkShapedNeighborhoodIterator.h.

◆ OffsetType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::OffsetType = typename Superclass::OffsetType

Inherit type alias from superclass

Definition at line 169 of file itkShapedNeighborhoodIterator.h.

◆ OffsetValueType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::OffsetValueType = typename OffsetType::OffsetValueType

Definition at line 170 of file itkShapedNeighborhoodIterator.h.

◆ PixelType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::PixelType = typename TImage::PixelType

Definition at line 159 of file itkShapedNeighborhoodIterator.h.

◆ RadiusType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::RadiusType = typename Superclass::RadiusType

Definition at line 171 of file itkShapedNeighborhoodIterator.h.

◆ RegionType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::RegionType = typename Superclass::RegionType

Definition at line 181 of file itkShapedNeighborhoodIterator.h.

◆ Self

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::Self = ShapedNeighborhoodIterator

Standard class type aliases.

Definition at line 165 of file itkShapedNeighborhoodIterator.h.

◆ SizeType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::SizeType = typename Superclass::SizeType

Definition at line 172 of file itkShapedNeighborhoodIterator.h.

◆ SizeValueType

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::SizeValueType = typename Superclass::SizeValueType

Definition at line 173 of file itkShapedNeighborhoodIterator.h.

◆ Superclass

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::Superclass = ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>

Definition at line 166 of file itkShapedNeighborhoodIterator.h.

Constructor & Destructor Documentation

◆ ShapedNeighborhoodIterator() [1/3]

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::ShapedNeighborhoodIterator ( )
default

Default constructor

◆ ~ShapedNeighborhoodIterator()

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::~ShapedNeighborhoodIterator ( )
overridedefault

Virtual destructor

◆ ShapedNeighborhoodIterator() [2/3]

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::ShapedNeighborhoodIterator ( const SizeType radius,
const ImageType ptr,
const RegionType region 
)
inline

Constructor which establishes the region size, neighborhood, and image over which to walk.

Definition at line 223 of file itkShapedNeighborhoodIterator.h.

◆ ShapedNeighborhoodIterator() [3/3]

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::ShapedNeighborhoodIterator ( const ShapedNeighborhoodIterator< TImage, TBoundaryCondition > &  o)
protecteddelete

Copy constructor

Member Function Documentation

◆ Begin() [1/3]

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
Iterator itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::Begin ( )
inline

Returns a const iterator for the neighborhood which points to the first pixel in the neighborhood.

Definition at line 249 of file itkShapedNeighborhoodIterator.h.

◆ Begin() [2/3]

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
Iterator itk::Neighborhood< TPixel, VDimension, TAllocator >::Begin
inline

Assignment operator

Definition at line 187 of file itkNeighborhood.h.

◆ Begin() [3/3]

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
ConstIterator itk::Neighborhood< TPixel, VDimension, TAllocator >::Begin
inline

Assignment operator

Definition at line 197 of file itkNeighborhood.h.

◆ End() [1/3]

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
Iterator itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::End ( )
inline

Assignment operator

Definition at line 254 of file itkShapedNeighborhoodIterator.h.

◆ End() [2/3]

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
Iterator itk::Neighborhood< TPixel, VDimension, TAllocator >::End
inline

STL-style iterator support.

Definition at line 182 of file itkNeighborhood.h.

◆ End() [3/3]

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
ConstIterator itk::Neighborhood< TPixel, VDimension, TAllocator >::End
inline

Assignment operator

Definition at line 192 of file itkNeighborhood.h.

◆ operator=()

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
Self& itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::operator= ( const Self orig)
inline

Assignment operator

Definition at line 235 of file itkShapedNeighborhoodIterator.h.

◆ PrintSelf()

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
void itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::PrintSelf ( std::ostream &  ,
Indent   
) const
overridevirtual

Standard itk print method

Reimplemented from itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >.

Member Data Documentation

◆ Dimension

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
constexpr unsigned int itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::Dimension = TImage::ImageDimension
staticconstexpr

Save the image dimension.

Definition at line 162 of file itkShapedNeighborhoodIterator.h.

◆ Superclass

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
friend itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::Superclass
protected

Assignment operator

Definition at line 264 of file itkShapedNeighborhoodIterator.h.


The documentation for this class was generated from the following file:
itk::ConstNeighborhoodIterator::IsAtEnd
ITK_ITERATOR_VIRTUAL bool IsAtEnd() const ITK_ITERATOR_FINAL
Definition: itkConstNeighborhoodIterator.h:353
itk::ShapedNeighborhoodIterator::ImageType
typename Superclass::ImageType ImageType
Definition: itkShapedNeighborhoodIterator.h:180
itk::ShapedNeighborhoodIterator< ImageType >::OffsetType
typename Superclass::OffsetType OffsetType
Definition: itkShapedNeighborhoodIterator.h:169
itk::NeighborhoodIterator::Iterator
typename Superclass::Iterator Iterator
Definition: itkNeighborhoodIterator.h:228