ITK  4.6.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:
* typedef Image<float, 3> ImageType;
* 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.

* typedef Image<float, 3> ImageType;
* ShapedNeighborhoodIterator<ImageType> it(radius, image, region);
* .
* .
* .
* it.ActivateOffset(offset1);
* it.ActivateOffset(offset2);
* it.ActivateOffset(offset3);
* etc..
* .
* .
* .
* 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 http://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 152 of file itkShapedNeighborhoodIterator.h.

Classes

struct  Iterator
 

Public Types

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

Public Member Functions

void ClearActiveList ()
 
const ConstIteratorEnd () const
 
Selfoperator= (const Self &orig)
 
virtual void PrintSelf (std::ostream &, Indent) const
 
virtual ~ShapedNeighborhoodIterator ()
 
 ShapedNeighborhoodIterator ()
 
 ShapedNeighborhoodIterator (const SizeType &radius, const ImageType *ptr, const RegionType &region)
 
IteratorBegin ()
 
IteratorEnd ()
 
- Public Member Functions inherited from itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >
 ConstShapedNeighborhoodIterator (const SizeType &radius, const ImageType *ptr, const RegionType &region)
 
void CreateActiveListFromNeighborhood (const NeighborhoodType &)
 
const IndexListTypeGetActiveIndexList () const
 
IndexListType::size_type GetActiveIndexListSize () const
 
Selfoperator++ ()
 
Selfoperator+= (const OffsetType &)
 
Selfoperator-- ()
 
Selfoperator-= (const OffsetType &)
 
virtual ~ConstShapedNeighborhoodIterator ()
 
const ConstIteratorBegin () const
 
const ConstIteratorEnd () const
 
 ConstShapedNeighborhoodIterator ()
 
void InitializeConstShapedNeighborhoodIterator ()
 
Selfoperator= (const Self &orig)
 
virtual void ActivateOffset (const OffsetType &off)
 
virtual void DeactivateOffset (const OffsetType &off)
 

Static Public Attributes

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

Protected Types

typedef
Superclass::NeighborIndexType 
NeighborIndexType
 

Protected Member Functions

void ActivateIndex (NeighborIndexType n)
 
void DeactivateIndex (NeighborIndexType n)
 
 ShapedNeighborhoodIterator (const ShapedNeighborhoodIterator &o)
 
- Protected Member Functions inherited from itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >
 ConstShapedNeighborhoodIterator (const ConstShapedNeighborhoodIterator &)
 

Protected Attributes

Iterator m_BeginIterator
 
Iterator m_EndIterator
 
- Protected Attributes inherited from itk::ConstShapedNeighborhoodIterator< TImage, TBoundaryCondition >
IndexListType m_ActiveIndexList
 
bool m_CenterIsActive
 
ConstIterator m_ConstBeginIterator
 
ConstIterator m_ConstEndIterator
 

Member Typedef Documentation

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

Definition at line 176 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 174 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 177 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 180 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 175 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 179 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 182 of file itkShapedNeighborhoodIterator.h.

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

Extract image type information.

Definition at line 157 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 178 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 272 of file itkShapedNeighborhoodIterator.h.

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

Inherit typedefs from superclass

Definition at line 169 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 170 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 158 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 171 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 181 of file itkShapedNeighborhoodIterator.h.

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

Standard class typedefs.

Definition at line 164 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 172 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 173 of file itkShapedNeighborhoodIterator.h.

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

Definition at line 166 of file itkShapedNeighborhoodIterator.h.

Constructor & Destructor Documentation

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

Default constructor

Definition at line 203 of file itkShapedNeighborhoodIterator.h.

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

Virtual destructor

Definition at line 212 of file itkShapedNeighborhoodIterator.h.

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

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

Copy constructor

Member Function Documentation

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition< TImage >>
void itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::ActivateIndex ( NeighborIndexType  )
inlineprotectedvirtual

Class is protected here so that it is not publicly accessible, but can be accessed by subclasses.. Add/Remove a neighborhood index to/from the active. Locations in the active list are the only accessible elements in the neighborhood. The argument is an index location calculated as an offset into a linear array which represents the image region defined by the radius of this iterator, with the smallest dimension as the fastest increasing index.

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

Definition at line 274 of file itkShapedNeighborhoodIterator.h.

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

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

Definition at line 250 of file itkShapedNeighborhoodIterator.h.

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition< TImage >>
void itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::ClearActiveList ( )
inlinevirtual

Removes all active pixels from this neighborhood.

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

Definition at line 259 of file itkShapedNeighborhoodIterator.h.

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition< TImage >>
void itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::DeactivateIndex ( NeighborIndexType  n)
inlineprotectedvirtual
template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition< TImage >>
Iterator& itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::End ( void  )
inline

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

Definition at line 251 of file itkShapedNeighborhoodIterator.h.

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

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

Definition at line 256 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 235 of file itkShapedNeighborhoodIterator.h.

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

Standard itk print method

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

Member Data Documentation

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

Save the image dimension.

Definition at line 161 of file itkShapedNeighborhoodIterator.h.

template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition< TImage >>
Iterator itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::m_BeginIterator
protected
template<typename TImage, typename TBoundaryCondition = ZeroFluxNeumannBoundaryCondition< TImage >>
Iterator itk::ShapedNeighborhoodIterator< TImage, TBoundaryCondition >::m_EndIterator
protected

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