KWStyle - itkImageRegionExclusionConstIteratorWithIndex.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkImageRegionExclusionConstIteratorWithIndex.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:39 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17 #ifndef __itkImageRegionExclusionConstIteratorWithIndex_h
18 #define __itkImageRegionExclusionConstIteratorWithIndex_h
19
20 #include "itkImageConstIteratorWithIndex.h"
21
22 namespace itk
23 {
24
25 /** \class ImageRegionExclusionConstIteratorWithIndex
26  *
27  *  \brief Multi-dimensional image iterator that walks an image region,
28  *  excluding a second region contained within the first.
29  * 
30  * ImageRegionExclusionConstIteratorWithIndex is a templated class to represent
31  * a multi-dimensional iterator. ImageRegionExclusionConstIteratorWithIndex is
32  * templated over the image type.  ImageRegionExclusionConstIteratorWithIndex
33  * is constrained to walk only within the specified region. The exclusion
34  * region is set after construction. By default the exclusion region is empty
35  * and the iterator will behave as the itk::ImageRegionIteratorWithIndex with a
36  * penalty in performance due to internal bounds checking.
37  *
38  * As with other ITK image iterators,
39  * ImageRegionExclusionConstIteratorWithIndex requires more information be
40  * specified before the iterator can be used than conventional
41  * iterators. Whereas the std::vector::iterator from the STL only needs to be
42  * passed a pointer to establish the iterator, the multi-dimensional image
43  * iterator needs a pointer, the size of the buffer, the size of the region,
44  * the start index of the buffer, and the start index of the region. To gain
45  * access to this information, ImageRegionExclusionConstIteratorWithIndex holds
46  * a reference to the image over which it is traversing.
47  *
48  * ImageRegionExclusionConstIteratorWithIndex assumes a particular layout of
49  * the image data. The is arranged in a 1D array as if it were
50  * [][][][slice][row][col] with Index[0] = col, Index[1] = row, Index[2] =
51  * slice, etc.
52  *
53  * The operator++ method provides a simple syntax for walking around a region
54  * of a multidimensional image. operator++ iterates across a row, constraining
55  * the movement to within a region of image. When the iterator reaches the
56  * boundary of the region along a row, the iterator automatically wraps to the
57  * next row, starting at the first pixel in the row that is part of the
58  * region. This allows for simple processing loops of the form:
59  *
60  * \example itkImageRegionExclusionConstIteratorWithIndex
61  *
62  * \code
63  * 
64  *  IteratorType it( image, image->GetRequestedRegion() );
65  *
66  *  it.SetExclusionRegion( exclusionRegion );
67  *
68  *  it.GoToBegin();
69  *
70  *  while( ! it.IsAtEnd() ) 
71  *  {  
72 IND **    it.Set( 100.0 + it.Get() );
73 IND **    ++it;
74 IND **  }
75  *
76  * \endcode
77  *
78  *  It also can be used for walking in the reverse direction like
79  *
80  * \code
81  * 
82  *  IteratorType it( image, image->GetRequestedRegion() );
83  *
84  *  it.SetExclusionRegion( exclusionRegion );
85  *  it.GoToEnd();
86  *
87  *  while( !it.IsAtBegin() ) 
88  *  {  
89 IND **    it.Set( 100.0 );
90 IND **    --it;
91 IND **  }
92  *
93  * \endcode
94  *
95  * \par MORE INFORMATION
96  * For a complete description of the ITK Image Iterators and their API, please
97  * see the Iterators chapter in the ITK Software Guide.  The ITK Software Guide
98  * is available in print and as a free .pdf download from http://www.itk.org.
99  *
100  * \ingroup ImageIterators
101  *
102  * \sa ImageConstIterator \sa ConditionalConstIterator
103  * \sa ConstNeighborhoodIterator \sa ConstShapedNeighborhoodIterator
104  * \sa ConstSliceIterator  \sa CorrespondenceDataStructureIterator 
105  * \sa FloodFilledFunctionConditionalConstIterator 
106  * \sa FloodFilledImageFunctionConditionalConstIterator 
107  * \sa FloodFilledImageFunctionConditionalIterator 
108  * \sa FloodFilledSpatialFunctionConditionalConstIterator 
109  * \sa FloodFilledSpatialFunctionConditionalIterator 
110  * \sa ImageConstIterator \sa ImageConstIteratorWithIndex 
111  * \sa ImageIterator \sa ImageIteratorWithIndex
112  * \sa ImageLinearConstIteratorWithIndex  \sa ImageLinearIteratorWithIndex 
113  * \sa ImageRandomConstIteratorWithIndex  \sa ImageRandomIteratorWithIndex 
114  * \sa ImageRegionConstIterator \sa ImageRegionConstIteratorWithIndex 
115  * \sa ImageRegionExclusionConstIteratorWithIndex 
116  * \sa ImageRegionExclusionIteratorWithIndex 
117  * \sa ImageRegionIterator  \sa ImageRegionIteratorWithIndex 
118  * \sa ImageRegionReverseConstIterator  \sa ImageRegionReverseIterator 
119  * \sa ImageReverseConstIterator  \sa ImageReverseIterator 
120  * \sa ImageSliceConstIteratorWithIndex  \sa ImageSliceIteratorWithIndex 
121  * \sa NeighborhoodIterator \sa PathConstIterator  \sa PathIterator 
122  * \sa ShapedNeighborhoodIterator  \sa SliceIterator 
123  * \sa ImageConstIteratorWithIndex */
124 template<typename TImage>
125 LEN class ITK_EXPORT ImageRegionExclusionConstIteratorWithIndex : public ImageConstIteratorWithIndex<TImage>
126 {
127 public:
128   /** Standard class typedefs. */
129   typedef ImageRegionExclusionConstIteratorWithIndex Self;
130 TDA   typedef ImageConstIteratorWithIndex<TImage>  Superclass;
131   
132   /** Index typedef support. While this was already typdef'ed in the superclass
133    * it needs to be redone here for this subclass to compile properly with gcc.
134    * Note that we have to rescope Index back to itk::Index to that is it not
135    * confused with ImageIterator::Index. */
136   typedef typename TImage::IndexType  IndexType;
137 TDA   typedef typename TImage::SizeType SizeType;
138
139   /** Image typedef support. While this was already typdef'ed in the superclass
140    * it needs to be redone here for this subclass to compile properly with gcc.
141    * Note that we have to rescope Image back to itk::Image to that is it not
142    * confused with ImageIterator::Image. */
143   typedef TImage ImageType;
144
145   /** PixelContainer typedef support. Used to refer to the container for
146    * the pixel data. While this was already typdef'ed in the superclass
147 LEN    * it needs to be redone here for this subclass to compile properly with gcc. */
148   typedef typename TImage::PixelContainer PixelContainer;
149 TDA   typedef typename PixelContainer::Pointer PixelContainerPointer;
150   
151   /** Region typedef support. While this was already typdef'ed in the superclass
152    * it needs to be redone here for this subclass to compile properly with gcc.
153    * Note that we have to rescope Region back to itk::ImageRegion so that is
154    * it not confused with ImageIterator::Index. */
155   typedef typename TImage::RegionType RegionType;
156
157   /** Default constructor. Needed since we provide a cast constructor. */
158 LEN   ImageRegionExclusionConstIteratorWithIndex() : ImageConstIteratorWithIndex<TImage>() {}
159   
160   /** Constructor establishes an iterator to walk a particular image and a
161    * particular region of that image. */
162   ImageRegionExclusionConstIteratorWithIndex(const TImage *ptr,
163                             const RegionType& region)
164 IND ****: ImageConstIteratorWithIndex<TImage>(ptr, region) {}
165
166   /** Constructor that can be used to cast from an ImageIterator to an
167 LEN    * ImageRegionExclusionConstIteratorWithIndex. Many routines return an ImageIterator but for a
168 LEN    * particular task, you may want an ImageRegionExclusionConstIteratorWithIndex.  Rather than
169    * provide overloaded APIs that return different types of Iterators, itk
170    * returns ImageIterators and uses constructors to cast from an
171    * ImageIterator to a ImageRegionExclusionConstIteratorWithIndex. */
172 LEN   ImageRegionExclusionConstIteratorWithIndex( const ImageConstIteratorWithIndex<TImage> &it)
173     { this->ImageConstIteratorWithIndex<TImage>::operator=(it); }
174
175   /** Increment (prefix) the fastest moving dimension of the iterator's index.
176    * This operator will constrain the iterator within the region (i.e. the
177    * iterator will automatically wrap from the end of the row of the region
178    * to the beginning of the next row of the region) up until the iterator
179    * tries to moves past the last pixel of the region.  Here, the iterator
180    * will be set to be one pixel past the end of the region.
181    * \sa operator++(int) */
182   Self & operator++();
183
184   /** Decrement (prefix) the fastest moving dimension of the iterator's index.
185    * This operator will constrain the iterator within the region (i.e. the
186 LEN    * iterator will automatically wrap from the beginning of the row of the region
187    * to the end of the next row of the region) up until the iterator
188    * tries to moves past the first pixel of the region.  Here, the iterator
189    * will be set to be one pixel past the beginning of the region.
190    * \sa operator--(int) */
191   Self & operator--();
192
193
194   /** Method to define the Exclusion region. The iterator will skip pixels 
195    * inside this region. 
196    * \warning The exclusion region must be completly containe inside the
197    * normal region used to construct the iterator. A border of at least on
198    * pixels should exist between the normal region and the exclusion region.
199    */
200   void SetExclusionRegion( const RegionType & region );
201
202   /** Set the exclusion region to be inset one pixel in from the
203    * region the iterator walks. This configures the iterator to only
204    * walk the pixels on the boundary of the region.
205    */
206   void SetExclusionRegionToInsetRegion();
207   
208 private:
209
210   RegionType      m_ExclusionRegion;
211
212   IndexType       m_ExclusionBegin;
213   IndexType       m_ExclusionEnd;
214
215 };
216
217 // end namespace itk
218
219 #ifndef ITK_MANUAL_INSTANTIATION
220 #include "itkImageRegionExclusionConstIteratorWithIndex.txx"
221 #endif
222
223 #endif 
224

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:14PM
© Kitware Inc.