KWStyle - itkConstNeighborhoodIterator.txx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkConstNeighborhoodIterator.txx.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:34 $
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 DEF #ifndef _itkConstNeighborhoodIterator_txx
18 DEF #define _itkConstNeighborhoodIterator_txx
19 #include "itkConstNeighborhoodIterator.h"
20 namespace itk {
21
22 template<class TImage, class TBoundaryCondition>
23 bool
24 ConstNeighborhoodIterator<TImage, TBoundaryCondition>
25 ::InBounds() const
26
27   if (m_IsInBoundsValid)
28     {
29     return m_IsInBounds;
30     }
31
32   bool ans = true;
33   for (unsigned int i=0; i<Dimension; i++)
34     {
35     if (m_Loop[i] < m_InnerBoundsLow[i] || m_Loop[i] >= m_InnerBoundsHigh[i])
36       {
37       m_InBounds[i] = ans = false;
38       }
39     else
40       {
41       m_InBounds[i] = true;
42       }
43     }
44   m_IsInBounds = ans;
45   m_IsInBoundsValid = true;
46   return ans;
47 }
48
49
50 EML
51 template<class TImage, class TBoundaryCondition>
52 typename ConstNeighborhoodIterator<TImage, TBoundaryCondition>::PixelType
53 ConstNeighborhoodIterator<TImage, TBoundaryCondition>
54 ::GetPixel(const unsigned n, bool& IsInBounds) const
55 {
56   // If the region the iterator is walking (padded by the neighborhood size)
57   // never bumps up against the bounds of the buffered region, then don't
58   // bother checking any boundary conditions
59   if (!m_NeedToUseBoundaryCondition)
60     {
61     IsInBounds = true;
62     return (m_NeighborhoodAccessorFunctor.Get(this->operator[](n)));
63     }
64
65   register unsigned int i;
66   OffsetValueType OverlapLow, OverlapHigh;
67   OffsetType temp, offset;
68   bool flag;
69
70   // Is this whole neighborhood in bounds?
71   if (this->InBounds())
72     {
73     IsInBounds = true;
74     return (m_NeighborhoodAccessorFunctor.Get(this->operator[](n)));
75     }
76   else
77     {
78     temp = this->ComputeInternalIndex(n);
79       
80     flag = true;
81
82     // Is this pixel in bounds?
83     for (i=0; i<Dimension; ++i)
84       {
85       if (m_InBounds[i])
86         {
87         offset[i] = 0; // this dimension in bounds
88         }
89       else  // part of this dimension spills out of bounds
90         {
91         // Calculate overlap for this dimension
92         OverlapLow = m_InnerBoundsLow[i] - m_Loop[i];
93         OverlapHigh =
94 LEN           static_cast<OffsetValueType>(this->GetSize(i) - ( (m_Loop[i]+2) - m_InnerBoundsHigh[i] ));
95
96         // 
97         if (temp[i] < OverlapLow)
98           {
99           flag = false;
100           offset[i] = OverlapLow - temp[i];
101           }
102         else if ( OverlapHigh < temp[i] )
103           {
104           flag = false;
105           offset[i] =  OverlapHigh - temp[i];
106           }
107         else offset[i] = 0;
108         }
109       }
110
111     if (flag) 
112       {
113       IsInBounds = true;
114 SEM       return ( m_NeighborhoodAccessorFunctor.Get(this->operator[](n)) ) ;
115       }
116     else 
117       {
118       IsInBounds = false;
119       return( m_NeighborhoodAccessorFunctor.BoundaryCondition( 
120                 temp, offset, this, this->m_BoundaryCondition) );
121       }
122     } 
123 }
124
125
126 template<class TImage, class TBoundaryCondition>
127 typename ConstNeighborhoodIterator<TImage, TBoundaryCondition>::OffsetType
128 ConstNeighborhoodIterator<TImage, TBoundaryCondition>
129 ::ComputeInternalIndex(unsigned int n) const
130 {
131   OffsetType ans;
132   long D = (long)Dimension;
133   unsigned long r;
134   r = (unsigned long)n;
135 SEM   for (long i = D-1; i >= 0 ; --i)
136     {
137     ans[i] = static_cast<OffsetValueType>(r / this->GetStride(i));
138     r = r % this->GetStride(i);
139     }
140   return ans;
141 }
142
143
144 template <class TImage, class TBoundaryCondition>
145 typename ConstNeighborhoodIterator<TImage, TBoundaryCondition>::RegionType
146 ConstNeighborhoodIterator<TImage, TBoundaryCondition>
147 ::GetBoundingBoxAsImageRegion() const
148 {
149   RegionType ans;
150   ans.SetIndex(this->GetIndex(0));
151   ans.SetSize(this->GetSize());
152   
153   return ans;
154 }
155
156 template<class TImage, class TBoundaryCondition>
157 ConstNeighborhoodIterator<TImage, TBoundaryCondition>
158 ::ConstNeighborhoodIterator()
159 {
160   IndexType zeroIndex; zeroIndex.Fill(0);
161   SizeType  zeroSize; zeroSize.Fill(0);
162
163   m_Bound.Fill(0);
164   m_Begin = 0;
165   m_BeginIndex.Fill(0);
166   // m_ConstImage
167   m_End   = 0;
168   m_EndIndex.Fill(0);
169   m_Loop.Fill(0);
170   m_Region.SetIndex(zeroIndex);
171   m_Region.SetSize(zeroSize);
172   
173   m_WrapOffset.Fill(0);
174
175   for (unsigned int i=0; i < Dimension; i++)
176     { m_InBounds[i] = false; }
177
178   this->ResetBoundaryCondition();
179
180   m_IsInBounds = false;
181   m_IsInBoundsValid = false;
182 }
183
184 template<class TImage, class TBoundaryCondition>
185 ConstNeighborhoodIterator<TImage, TBoundaryCondition>
186 ::ConstNeighborhoodIterator(const Self& orig)
187 IND **: Neighborhood<InternalPixelType *, Dimension>(orig)
188 {
189   m_Bound      = orig.m_Bound;
190   m_Begin      = orig.m_Begin;
191   m_BeginIndex = orig.m_BeginIndex;  
192   m_ConstImage = orig.m_ConstImage;
193   m_End        = orig.m_End;
194   m_EndIndex   = orig.m_EndIndex;
195   m_Loop       = orig.m_Loop;
196   m_Region     = orig.m_Region;
197   m_WrapOffset = orig.m_WrapOffset;
198
199   m_InternalBoundaryCondition = orig.m_InternalBoundaryCondition;
200   m_NeedToUseBoundaryCondition = orig.m_NeedToUseBoundaryCondition;
201   for (unsigned int i = 0; i < Dimension; ++i)
202     {
203     m_InBounds[i] = orig.m_InBounds[i];
204     }
205   m_IsInBoundsValid = orig.m_IsInBoundsValid;
206   m_IsInBounds = orig.m_IsInBounds;
207
208   m_InnerBoundsLow  = orig.m_InnerBoundsLow;
209   m_InnerBoundsHigh = orig.m_InnerBoundsHigh;
210
211   // Check to see if the default boundary
212   // conditions have been overridden.
213   if ( orig.m_BoundaryCondition ==
214 LEN        static_cast<ImageBoundaryConditionConstPointerType>(&orig.m_InternalBoundaryCondition ))
215     {
216     this->ResetBoundaryCondition();
217     }
218   else 
219     { m_BoundaryCondition = orig.m_BoundaryCondition; }
220
221   m_NeighborhoodAccessorFunctor = orig.m_NeighborhoodAccessorFunctor;
222   
223 }
224
225 template<class TImage, class TBoundaryCondition>
226 void
227 ConstNeighborhoodIterator<TImage, TBoundaryCondition>
228 ::SetEndIndex()
229 {
230   if (m_Region.GetNumberOfPixels() > 0)
231     {
232     m_EndIndex = m_Region.GetIndex();
233     m_EndIndex[Dimension-1] = m_Region.GetIndex()[Dimension-1] +
234 IND ******static_cast<long>(m_Region.GetSize()[Dimension-1]);
235     }
236   else
237     {
238     // Region has no pixels, so set the end index to be the begin index
239     m_EndIndex = m_Region.GetIndex();
240     }
241 }
242
243 template<class TImage, class TBoundaryCondition> 
244 typename ConstNeighborhoodIterator<TImage, TBoundaryCondition>::NeighborhoodType
245 ConstNeighborhoodIterator<TImage, TBoundaryCondition>
246 ::GetNeighborhood() const
247 {
248   register unsigned int i;
249   OffsetType OverlapLow, OverlapHigh, temp, offset;
250   bool flag;
251
252   const ConstIterator _end = this->End();
253   NeighborhoodType ans;
254   typename NeighborhoodType::Iterator ans_it;
255   ConstIterator this_it;
256
257   ans.SetRadius( this->GetRadius() );
258
259   if (m_NeedToUseBoundaryCondition == false)
260     {
261     for (ans_it = ans.Begin(), this_it = this->Begin();
262 IND *********this_it < _end; ans_it++, this_it++)
263       { *ans_it = m_NeighborhoodAccessorFunctor.Get(*this_it); }
264     }
265   else if (InBounds())
266     {
267     for (ans_it = ans.Begin(), this_it = this->Begin();
268 IND *********this_it < _end; ans_it++, this_it++)
269       { *ans_it = m_NeighborhoodAccessorFunctor.Get(*this_it); }
270     }
271   else
272     {
273     // Calculate overlap & initialize index
274     for (i=0; i<Dimension; i++)
275       {
276       OverlapLow[i] = m_InnerBoundsLow[i] - m_Loop[i];
277       OverlapHigh[i]=
278 LEN         static_cast<OffsetValueType>(this->GetSize(i)) - ( (m_Loop[i]+2) - m_InnerBoundsHigh[i] );
279       temp[i] = 0;
280       }
281
282     // Iterate through neighborhood
283     for (ans_it = ans.Begin(), this_it = this->Begin();
284 IND *********this_it < _end; ans_it++, this_it++)
285       {
286       flag = true;
287           
288       // Is this pixel in bounds?
289       for (i=0; i<Dimension; ++i)
290         {
291         if (m_InBounds[i]) offset[i] = 0; // this dimension in bounds
292         else  // part of this dimension spills out of bounds
293           {
294           if (temp[i] < OverlapLow[i])
295             {
296             flag = false;
297             offset[i] = OverlapLow[i] - temp[i];
298             }
299           else if ( OverlapHigh[i] < temp[i] )
300             {
301             flag = false;
302             offset[i] =  OverlapHigh[i] - temp[i];
303             }
304           else offset[i] = 0;
305           }
306         }
307           
308       if (flag) *ans_it = m_NeighborhoodAccessorFunctor.Get(*this_it);
309       else *ans_it = m_NeighborhoodAccessorFunctor.BoundaryCondition( 
310                           temp, offset, this, this->m_BoundaryCondition);
311         
312 IND ********m_BoundaryCondition->operator()(temp, offset, this);
313           
314       for (i=0; i<Dimension; ++i)  // Update index
315         {
316         temp[i]++;
317 LEN         if ( temp[i] == static_cast<OffsetValueType>(this->GetSize(i)) ) temp[i]= 0; 
318         else break;
319         }
320       } 
321     }
322   return ans;
323 }
324
325 template<class TImage, class TBoundaryCondition>
326 void
327 ConstNeighborhoodIterator<TImage, TBoundaryCondition>
328 ::GoToBegin()
329 {
330   this->SetLocation( m_BeginIndex );
331 }
332
333 template<class TImage, class TBoundaryCondition>
334 void
335 ConstNeighborhoodIterator<TImage, TBoundaryCondition>
336 ::GoToEnd()
337 {
338   this->SetLocation( m_EndIndex );
339 }
340
341 template<class TImage, class TBoundaryCondition>
342 void ConstNeighborhoodIterator<TImage, TBoundaryCondition>
343 ::Initialize(const SizeType &radius, const ImageType *ptr,
344              const RegionType ®ion)
345
346   m_ConstImage = ptr;
347   m_Region = region;
348   const IndexType regionIndex = region.GetIndex();
349
350   this->SetRadius(radius);
351   this->SetBeginIndex(region.GetIndex());
352   this->SetLocation(region.GetIndex());
353   this->SetBound(region.GetSize());
354   this->SetEndIndex();
355   
356   m_Begin = ptr->GetBufferPointer() + ptr->ComputeOffset(regionIndex);
357
358   m_End = ptr->GetBufferPointer() + ptr->ComputeOffset( m_EndIndex );
359
360   // now determine whether boundary conditions are going to be needed
361   const IndexType bStart = ptr->GetBufferedRegion().GetIndex();
362   const SizeType  bSize  = ptr->GetBufferedRegion().GetSize();
363   const IndexType rStart = region.GetIndex();
364   const SizeType  rSize  = region.GetSize();
365
366   long  overlapLow, overlapHigh;
367
368   m_NeedToUseBoundaryCondition = false;
369   for (unsigned long i = 0; i < Dimension; ++i)
370     {
371     overlapLow = static_cast<long>((rStart[i] - radius[i]) - bStart[i]);
372 LEN     overlapHigh= static_cast<long>((bStart[i] + bSize[i]) - (rStart[i] + rSize[i] + radius[i]));
373
374     if (overlapLow < 0) // out of bounds condition, define a region of 
375       {
376       m_NeedToUseBoundaryCondition = true;
377       break;
378       }
379
380     if (overlapHigh < 0)
381       {
382       m_NeedToUseBoundaryCondition = true;
383       break;
384       }
385     }
386
387   m_IsInBoundsValid = false;
388   m_IsInBounds = false;
389 }
390
391 template<class TImage, class TBoundaryCondition>
392 ConstNeighborhoodIterator<TImage, TBoundaryCondition> &
393 ConstNeighborhoodIterator<TImage, TBoundaryCondition>
394 ::operator=(const Self& orig)
395 {
396   Superclass::operator=(orig);
397
398   m_Bound        = orig.m_Bound;
399   m_Begin        = orig.m_Begin;
400   m_ConstImage   = orig.m_ConstImage;
401   m_End          = orig.m_End;
402   m_EndIndex     = orig.m_EndIndex;
403   m_Loop         = orig.m_Loop;
404   m_Region       = orig.m_Region;
405   m_BeginIndex = orig.m_BeginIndex;
406   m_WrapOffset = orig.m_WrapOffset;
407
408   m_InternalBoundaryCondition = orig.m_InternalBoundaryCondition;
409   m_NeedToUseBoundaryCondition = orig.m_NeedToUseBoundaryCondition;
410   
411   m_InnerBoundsLow  = orig.m_InnerBoundsLow;
412   m_InnerBoundsHigh = orig.m_InnerBoundsHigh;
413   
414   for (unsigned int i = 0; i < Dimension; ++i)
415     {
416     m_InBounds[i] = orig.m_InBounds[i];
417     }
418   m_IsInBoundsValid = orig.m_IsInBoundsValid;
419   m_IsInBounds = orig.m_IsInBounds;
420
421   // Check to see if the default boundary conditions
422   // have been overridden.
423   if (orig.m_BoundaryCondition ==
424 LEN       static_cast<ImageBoundaryConditionConstPointerType>( &orig.m_InternalBoundaryCondition ) )
425     {
426     this->ResetBoundaryCondition();
427     }
428   else m_BoundaryCondition = orig.m_BoundaryCondition;
429   m_NeighborhoodAccessorFunctor = orig.m_NeighborhoodAccessorFunctor;
430
431   return *this;
432 }
433
434 template<class TImage, class TBoundaryCondition>
435 ConstNeighborhoodIterator<TImage, TBoundaryCondition> &
436 ConstNeighborhoodIterator<TImage, TBoundaryCondition>
437 ::operator++()
438 {
439   unsigned int i;
440   Iterator it;
441   const Iterator _end = Superclass::End();
442
443   // Repositioning neighborhood, previous bounds check on neighborhood
444   // location is invalid.
445   m_IsInBoundsValid = false;
446   
447   // Increment pointers.
448   for (it = Superclass::Begin(); it < _end; ++it)
449     {
450     (*it)++;
451     }
452   
453   // Check loop bounds, wrap & add pointer offsets if needed.
454   for (i=0; i<Dimension; ++i)
455     {
456     m_Loop[i]++;
457     if ( m_Loop[i] == m_Bound[i] )
458       {
459       m_Loop[i] = m_BeginIndex[i];
460       for (it = Superclass::Begin(); it < _end; ++it)
461         {
462         (*it) += m_WrapOffset[i];
463         }
464       }        
465     else break;
466     }
467   return *this;
468 }
469
470 template<class TImage, class TBoundaryCondition>
471 ConstNeighborhoodIterator<TImage, TBoundaryCondition> &
472 ConstNeighborhoodIterator<TImage, TBoundaryCondition>
473 ::operator--()
474 {
475   unsigned int i;
476   Iterator it;
477   const Iterator _end = Superclass::End();
478   
479   // Repositioning neighborhood, previous bounds check on neighborhood
480   // location is invalid.
481   m_IsInBoundsValid = false;
482   
483   // Decrement pointers.
484   for (it = Superclass::Begin(); it < _end; ++it)
485     {
486     (*it)--;
487     }
488   
489   // Check loop bounds, wrap & add pointer offsets if needed.
490   for (i=0; i<Dimension; ++i)
491     {
492     if (m_Loop[i] == m_BeginIndex[i])
493       {
494       m_Loop[i]= m_Bound[i] - 1;
495       for (it = Superclass::Begin(); it < _end; ++it)
496         {
497         (*it) -= m_WrapOffset[i];
498         }
499       }        
500     else
501       {
502       m_Loop[i]--;
503       break;
504       }
505     }
506   return *this;
507 }
508
509 template<class TImage, class TBoundaryCondition>
510 void
511 ConstNeighborhoodIterator<TImage, TBoundaryCondition>
512 ::PrintSelf(std::ostream &os, Indent indent) const
513 {
514   unsigned int i;
515   os << indent;
516   os << "ConstNeighborhoodIterator {this= " << this;
517   os << ", m_Region = { Start = {";
518   for (i=0; i < Dimension; ++i) os << m_Region.GetIndex()[i] << " ";
519   os << "}, Size = { ";
520   for (i=0; i < Dimension; ++i) os << m_Region.GetSize()[i] << " ";
521   os << "} }";
522   os << ", m_BeginIndex = { ";
523   for (i=0; i < Dimension; ++i) os << m_BeginIndex[i] << " ";
524   os << "} , m_EndIndex = { ";
525   for (i=0; i < Dimension; ++i) os << m_EndIndex[i] << " ";
526   os << "} , m_Loop = { ";
527   for (i=0; i < Dimension; ++i) os << m_Loop[i] << " ";
528   os << "}, m_Bound = { ";
529   for (i=0; i < Dimension; ++i) os << m_Bound[i] << " ";
530   os << "}, m_IsInBounds = {" << m_IsInBounds;
531   os << "}, m_IsInBoundsValid = {" << m_IsInBoundsValid;
532   os << "}, m_WrapOffset = { ";
533   for (i=0; i < Dimension; ++i) os << m_WrapOffset[i] << " ";
534   os << ", m_Begin = " << m_Begin;
535   os << ", m_End = " << m_End;
536   os << "}"  << std::endl;
537
538   os << indent << ",  m_InnerBoundsLow = { ";
539   for (i = 0; i<Dimension; i++) os << m_InnerBoundsLow[i] << " ";
540   os << "}, m_InnerBoundsHigh = { ";
541   for (i = 0; i<Dimension; i++) os << m_InnerBoundsHigh[i] << " ";
542   os << "} }" << std::endl;
543   Superclass::PrintSelf(os, indent.GetNextIndent());  
544 }
545
546 template<class TImage, class TBoundaryCondition>
547 void ConstNeighborhoodIterator<TImage, TBoundaryCondition>
548 ::SetBound(const SizeType& size)
549 {
550   SizeType radius  = this->GetRadius();
551   const OffsetValueType *offset   = m_ConstImage->GetOffsetTable();
552   const IndexType imageBRStart  = m_ConstImage->GetBufferedRegion().GetIndex();
553   SizeType imageBRSize = m_ConstImage->GetBufferedRegion().GetSize();
554
555   // Set the bounds and the wrapping offsets. Inner bounds are the loop
556   // indicies where the iterator will begin to overlap the edge of the image
557   // buffered region.
558   for (unsigned int i=0; i<Dimension; ++i)
559     {
560 LEN     m_Bound[i]          = m_BeginIndex[i] + static_cast<IndexValueType>(size[i]);
561 LEN     m_InnerBoundsHigh[i]= static_cast<IndexValueType>(imageBRStart[i] + ( imageBRSize[i]) - static_cast<SizeValueType>(radius[i]) );
562 LEN     m_InnerBoundsLow[i] = static_cast<IndexValueType>(imageBRStart[i] + radius[i]);
563 LEN     m_WrapOffset[i]     = (static_cast<OffsetValueType>(imageBRSize[i]) - ( m_Bound[i]
564 LEN                                                                                 - m_BeginIndex[i] )) * offset[i];
565     }
566   m_WrapOffset[Dimension-1] = 0; // last offset is zero because there are no
567 IND *********************************// higher dimensions  
568 }
569
570
571 template<class TImage, class TBoundaryCondition>
572 void ConstNeighborhoodIterator<TImage, TBoundaryCondition>
573 ::SetPixelPointers(const IndexType &pos)
574 {
575   const Iterator _end = Superclass::End();
576   InternalPixelType * Iit;
577   ImageType *ptr = const_cast<ImageType *>(m_ConstImage.GetPointer());
578   const SizeType size = this->GetSize();
579   const OffsetValueType *OffsetTable = m_ConstImage->GetOffsetTable();
580   const SizeType radius = this->GetRadius();
581
582   unsigned int i;
583   Iterator Nit;
584   SizeType loop;
585   for (i=0; i<Dimension; ++i) loop[i]=0;
586
587   // Find first "upper-left-corner"  pixel address of neighborhood
588   Iit = ptr->GetBufferPointer() + ptr->ComputeOffset(pos);
589
590   for (i = 0; i<Dimension; ++i)
591     {
592     Iit -= radius[i] * OffsetTable[i];
593     }
594
595   // Compute the rest of the pixel addresses
596   for (Nit = Superclass::Begin(); Nit != _end; ++Nit)
597     {
598     *Nit = Iit;
599     ++Iit;
600     for (i = 0; i <Dimension; ++i)
601       {
602       loop[i]++;
603       if ( loop[i] == size[i] )
604         {
605         if (i==Dimension-1) break;
606         Iit +=  OffsetTable[i+1] - OffsetTable[i] * static_cast<long>(size[i]);
607         loop[i]= 0;
608         }
609       else break;
610       }
611     }
612 }
613
614 template<class TImage, class TBoundaryCondition>
615 ConstNeighborhoodIterator<TImage, TBoundaryCondition> &
616 ConstNeighborhoodIterator<TImage, TBoundaryCondition>
617 ::operator+=(const OffsetType & idx)
618 {
619   unsigned int i;
620   Iterator it;
621   const Iterator _end = this->End();
622   OffsetValueType accumulator = 0;
623   const OffsetValueType* stride = this->GetImagePointer()->GetOffsetTable();
624
625   // Repositioning neighborhood, previous bounds check on neighborhood
626   // location is invalid.
627   m_IsInBoundsValid = false;
628   
629   // Offset from the increment in the lowest dimension
630   accumulator += idx[0];
631   
632   // Offsets from the stride lengths in each dimension.
633   //
634   // Because the image offset table is based on its buffer size and not its
635   // requested region size, we don't have to worry about adding in the wrapping
636   // offsets. 
637   for (i = 1; i< Dimension; ++i)
638     {
639     accumulator += idx[i] * stride[i];
640     }
641
642   // Increment pointers.
643   for (it = this->Begin(); it < _end; ++it)
644     {
645     (*it) += accumulator;
646     }
647
648   // Update loop counter values
649   m_Loop += idx;
650
651   return *this;
652 }
653
654 template<class TImage, class TBoundaryCondition>
655 ConstNeighborhoodIterator<TImage, TBoundaryCondition> &
656 ConstNeighborhoodIterator<TImage, TBoundaryCondition> 
657 ::operator-=(const OffsetType & idx)
658 {
659   unsigned int i;
660   Iterator it;
661   const Iterator _end = this->End();
662   OffsetValueType accumulator = 0;
663   const OffsetValueType* stride = this->GetImagePointer()->GetOffsetTable();
664
665   // Repositioning neighborhood, previous bounds check on neighborhood
666   // location is invalid.
667   m_IsInBoundsValid = false;
668   
669   // Offset from the increment in the lowest dimension
670   accumulator += idx[0];
671   
672   // Offsets from the stride lengths in each dimension.
673   //
674   // Because the image offset table is based on its buffer size and not its
675   // requested region size, we don't have to worry about adding in the wrapping
676   // offsets. 
677   for (i = 1; i< Dimension; ++i)
678     {
679     accumulator += idx[i] * stride[i];
680     }
681
682   // Increment pointers.
683   for (it = this->Begin(); it < _end; ++it)
684     {
685     (*it) -= accumulator;
686     }
687
688   // Update loop counter values
689   m_Loop -= idx;
690
691   return *this;
692 }
693
694
695 EML
696 // namespace itk
697
698 #endif
699

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