ITK  5.0.0
Insight Segmentation and Registration Toolkit
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected 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 >:

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 neighbohood 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
Wiki Examples:

Definition at line 153 of file itkShapedNeighborhoodIterator.h.

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

void PrintSelf (std::ostream &, Indent) const override
 
 ShapedNeighborhoodIterator ()=default
 
 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, TBoundaryCondition >
void CreateActiveListFromNeighborhood (const NeighborhoodType &)
 
const IndexListTypeGetActiveIndexList () const
 
IndexListType::size_type GetActiveIndexListSize () const
 
Selfoperator++ ()
 
Selfoperator+= (const OffsetType &)
 
Selfoperator-- ()
 
Selfoperator-= (const OffsetType &)
 
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
 

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
 

Protected Types

using NeighborIndexType = typename Superclass::NeighborIndexType
 

Protected Member Functions

 ShapedNeighborhoodIterator (const ShapedNeighborhoodIterator &o)=delete
 
- 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

friend Superclass
 
- Protected Attributes inherited from itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >
IndexListType m_ActiveIndexList
 
bool m_CenterIsActive { false }
 

Member Typedef Documentation

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

Definition at line 178 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 176 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 179 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 182 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 177 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 181 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 184 of file itkShapedNeighborhoodIterator.h.

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

Extract image type information.

Definition at line 159 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 180 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 260 of file itkShapedNeighborhoodIterator.h.

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

Inherit type alias from superclass

Definition at line 171 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 172 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 160 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 173 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 183 of file itkShapedNeighborhoodIterator.h.

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

Standard class type aliases.

Definition at line 166 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 174 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 175 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 168 of file itkShapedNeighborhoodIterator.h.

Constructor & Destructor Documentation

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

Default constructor

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

Virtual destructor

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

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

Copy constructor

Member Function Documentation

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

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

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

Assignment operator

Definition at line 234 of file itkShapedNeighborhoodIterator.h.

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

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

Save the image dimension.

Definition at line 163 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 255 of file itkShapedNeighborhoodIterator.h.


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