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

#include <itkShapedNeighborhoodIterator.h>

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
ShapedImageNeighborhoodRange
ITK Sphinx Examples:
  • <a href=
  • <a href=
  • <a href=

Definition at line 148 of file itkShapedNeighborhoodIterator.h.

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

Classes

struct  Iterator
 

Public Types

using BoundaryConditionType = TBoundaryCondition
 
using ImageBoundaryConditionPointerType = ImageBoundaryCondition< ImageType > *
 
using ImageType = TImage
 
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 OffsetValueType = typename OffsetType::OffsetValueType
 
using PixelType = typename TImage::PixelType
 
using RegionType = typename TImage::RegionType
 
using Self = ShapedNeighborhoodIterator
 
using SizeValueType = typename SizeType::SizeValueType
 
using Superclass = ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >
 
- Public Types inherited from itk::ConstShapedNeighborhoodIterator< TImage, ZeroFluxNeumannBoundaryCondition< TImage > >
using BoundaryConditionType = ZeroFluxNeumannBoundaryCondition< TImage >
 
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 OffsetValueType = typename OffsetType::OffsetValueType
 
using PixelType = typename TImage::PixelType
 
using RegionType = typename TImage::RegionType
 
using Self = ConstShapedNeighborhoodIterator
 
using SizeValueType = typename SizeType::SizeValueType
 
using Superclass = NeighborhoodIterator< TImage, ZeroFluxNeumannBoundaryCondition< TImage > >
 

Public Member Functions

ConstIterator Begin () const
 
ConstIterator End () const
 
void SetCenterPixel (const PixelType &p)
 
void SetPixel (const OffsetType o, const PixelType &v)
 
void SetPixel (const unsigned int i, const PixelType &v)
 
void SetPixel (const unsigned int i, const PixelType &v, bool &status)
 
 ShapedNeighborhoodIterator ()=default
 
 ShapedNeighborhoodIterator (const ShapedNeighborhoodIterator &o)=delete
 
 ShapedNeighborhoodIterator (const SizeType &radius, const ImageType *ptr, const RegionType &region)
 
 ~ShapedNeighborhoodIterator () override=default
 
Selfoperator= (const Self &orig)
 
Iterator Begin ()
 
Iterator End ()
 
- Public Member Functions inherited from itk::ConstShapedNeighborhoodIterator< TImage, ZeroFluxNeumannBoundaryCondition< TImage > >
const IndexListTypeGetActiveIndexList () const
 
IndexListType::size_type GetActiveIndexListSize () const
 
Selfoperator++ ()
 
Selfoperator+= (const OffsetType &)
 
Selfoperator-- ()
 
Selfoperator-= (const OffsetType &)
 
void PrintSelf (std::ostream &, Indent) const override
 
ConstIterator Begin () const
 
ConstIterator End () const
 
 ConstShapedNeighborhoodIterator ()=default
 
 ConstShapedNeighborhoodIterator (const SizeType &radius, const ImageType *ptr, const RegionType &region)
 
 ConstShapedNeighborhoodIterator (const ConstShapedNeighborhoodIterator &)=delete
 
 ~ConstShapedNeighborhoodIterator () override=default
 
Selfoperator= (const Self &orig)
 
InternalPixelTypeGetCenterPointer ()
 
void ActivateOffset (const OffsetType &off)
 
void DeactivateOffset (const OffsetType &off)
 
void ActivateOffsets (const TOffsets &offsets)
 
void ClearActiveList ()
 
void CreateActiveListFromNeighborhood (const Neighborhood< TNeighborPixel, Self::Dimension > &)
 
void CreateActiveListFromNeighborhood (const NeighborhoodType &neighborhood)
 

Static Public Attributes

static constexpr unsigned int Dimension = TImage::ImageDimension
 
- Static Public Attributes inherited from itk::ConstShapedNeighborhoodIterator< TImage, ZeroFluxNeumannBoundaryCondition< TImage > >
static constexpr unsigned int Dimension
 

Protected Types

using NeighborIndexType = typename NeighborhoodType::NeighborIndexType
 

Protected Attributes

friend Superclass
 
- Protected Attributes inherited from itk::ConstShapedNeighborhoodIterator< TImage, ZeroFluxNeumannBoundaryCondition< TImage > >
IndexListType m_ActiveIndexList
 
bool m_CenterIsActive
 

Friends

struct ConstIterator
 

Additional Inherited Members

- Protected Member Functions inherited from itk::ConstShapedNeighborhoodIterator< TImage, ZeroFluxNeumannBoundaryCondition< TImage > >
void ActivateIndex (NeighborIndexType)
 
void DeactivateIndex (NeighborIndexType)
 
void SetCenterPixel (const PixelType &p)
 
void SetPixel (const OffsetType o, const PixelType &v)
 
void SetPixel (const unsigned int i, const PixelType &v)
 
void SetPixel (const unsigned int i, const PixelType &v, bool &status)
 

Member Typedef Documentation

◆ BoundaryConditionType

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

Typedef for boundary condition type.

Definition at line 110 of file itkConstShapedNeighborhoodIterator.h.

◆ ImageBoundaryConditionPointerType

template<typename TImage , typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >::ImageBoundaryConditionPointerType = ImageBoundaryCondition<ImageType> *

Typedef for generic boundary condition pointer

Definition at line 113 of file itkConstShapedNeighborhoodIterator.h.

◆ ImageType

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

Typedef support for common objects

Definition at line 94 of file itkConstShapedNeighborhoodIterator.h.

◆ IndexListType

template<typename TImage , typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >::IndexListType = std::list<NeighborIndexType>

An stl storage container type that can be sorted. The type used for the list of active offsets in the neighborhood.

Definition at line 104 of file itkConstShapedNeighborhoodIterator.h.

◆ IndexType

template<typename TImage , typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >::IndexType = Index<Self::Dimension>

Definition at line 96 of file itkConstShapedNeighborhoodIterator.h.

◆ IndexValueType

template<typename TImage , typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >::IndexValueType = typename IndexType::IndexValueType

Definition at line 97 of file itkConstShapedNeighborhoodIterator.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 153 of file itkShapedNeighborhoodIterator.h.

◆ NeighborhoodType

template<typename TImage , typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >::NeighborhoodType = Neighborhood<PixelType, Self::Dimension>

Definition at line 98 of file itkConstShapedNeighborhoodIterator.h.

◆ NeighborIndexType

template<typename TImage , typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >::NeighborIndexType = typename NeighborhoodType::NeighborIndexType
protected

Definition at line 100 of file itkConstShapedNeighborhoodIterator.h.

◆ OffsetValueType

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

Definition at line 165 of file itkShapedNeighborhoodIterator.h.

◆ PixelType

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

Definition at line 154 of file itkShapedNeighborhoodIterator.h.

◆ RegionType

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

Definition at line 95 of file itkConstShapedNeighborhoodIterator.h.

◆ Self

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

Standard class type aliases.

Definition at line 160 of file itkShapedNeighborhoodIterator.h.

◆ SizeValueType

template<typename TImage , typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
using itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >::SizeValueType = typename SizeType::SizeValueType

Definition at line 91 of file itkConstShapedNeighborhoodIterator.h.

◆ Superclass

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

Definition at line 161 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 ShapedNeighborhoodIterator< TImage, TBoundaryCondition > &  o)
delete

Copy constructor

◆ ShapedNeighborhoodIterator() [3/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 221 of file itkShapedNeighborhoodIterator.h.

Member Function Documentation

◆ Begin() [1/2]

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 243 of file itkShapedNeighborhoodIterator.h.

◆ Begin() [2/2]

template<typename TImage , typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
ConstIterator itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >::Begin ( ) const
inline

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

Definition at line 241 of file itkConstShapedNeighborhoodIterator.h.

◆ End() [1/2]

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

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

Definition at line 248 of file itkShapedNeighborhoodIterator.h.

◆ End() [2/2]

template<typename TImage , typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
ConstIterator itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >::End ( ) const
inline

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

Definition at line 249 of file itkConstShapedNeighborhoodIterator.h.

◆ operator=()

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

Assignment operator

Definition at line 233 of file itkShapedNeighborhoodIterator.h.

◆ SetCenterPixel()

template<typename TImage , typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
void itk::NeighborhoodIterator< TImage, TBoundaryCondition >::SetCenterPixel ( const PixelType p)
inline

Returns the central pixel of the neighborhood.

Definition at line 417 of file itkNeighborhoodIterator.h.

◆ SetPixel() [1/3]

template<typename TImage , typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
void itk::NeighborhoodIterator< TImage, TBoundaryCondition >::SetPixel ( const OffsetType  o,
const PixelType v 
)
inline

Set the pixel at offset o from the neighborhood center

Definition at line 416 of file itkNeighborhoodIterator.h.

◆ SetPixel() [2/3]

template<typename TImage , typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
void itk::NeighborhoodIterator< TImage, TBoundaryCondition >::SetPixel ( const unsigned int  i,
const PixelType v 
)

Set the pixel at the ith location.

◆ SetPixel() [3/3]

template<typename TImage , typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
void itk::NeighborhoodIterator< TImage, TBoundaryCondition >::SetPixel ( const unsigned int  i,
const PixelType v,
bool &  status 
)

Special SetPixel method which quietly ignores out-of-bounds attempts. Sets status TRUE if pixel has been set, FALSE otherwise.

Friends And Related Function Documentation

◆ ConstIterator

template<typename TImage , typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition<TImage>>
friend struct ConstIterator
friend

Definition at line 419 of file itkConstShapedNeighborhoodIterator.h.

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 157 of file itkShapedNeighborhoodIterator.h.

◆ Superclass

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

Definition at line 258 of file itkShapedNeighborhoodIterator.h.


The documentation for this class was generated from the following file: