OTB  6.7.0
Orfeo Toolbox
otbSubsampledImageRegionConstIterator.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  * Copyright (C) 2007-2012 Institut Mines Telecom / Telecom Bretagne
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 
23 #ifndef otbSubsampledImageRegionConstIterator_h
24 #define otbSubsampledImageRegionConstIterator_h
25 
27 
28 namespace otb {
29 
42 template <class TImage>
44  : public itk::ImageRegionConstIterator<TImage>
45 {
46 public:
47 
51 
53  itkTypeMacro(SubsampledImageRegionConstIterator, ImageRegionConstIterator);
54 
59  itkStaticConstMacro(ImageIteratorDimension, unsigned int,
60  Superclass::ImageIteratorDimension);
61 
64  typedef typename Superclass::IndexType IndexType;
65 
68  typedef typename Superclass::SizeType SizeType;
69 
72 
75  typedef typename Superclass::ImageType ImageType;
76 
79  //typedef typename Superclass::OffsetType OffsetType;
80  typedef unsigned long OffsetType;
81 
87 
90 
92  typedef typename Superclass::PixelType PixelType;
93 
97 
99  //typedef typename Superclass::IndexValueType IndexValueType;
100  typedef typename IndexType::IndexValueType IndexValueType;
101 
104 
107  SubsampledImageRegionConstIterator (const ImageType * ptr, const RegionType &region);
108 
116 
124 
126  void SetSubsampleFactor (IndexValueType factor);
127 
129  void SetSubsampleFactor(const IndexType& factor);
130 
132  {
133  return this->m_SubsampleFactor;
134  }
135 
138  void GoToBegin();
139 
142  void GoToEnd();
143 
150  bool IsAtBegin(void) const
151  {
152  return (this->m_Offset <= m_SubSampledBeginOffset);
153  }
154 
162  bool IsAtEnd(void) const
163  {
164  return (this->m_Offset >= m_SubSampledEndOffset);
165  }
166 
170  void SetIndex(const IndexType& ind) override;
171 
174  {
175  return Superclass::GetIndex();
176  }
177 
185  Self & operator ++()
186  {
187  // On the contrary to itk::ImageRegionConstIterator, m_Offset to
188  // not incremented before the test
189  if (this->m_Offset + m_SubsampleFactor[0] >= this->m_SpanEndOffset)
190  {
191  this->Increment();
192  }
193  else
194  {
195  // Now, the increment is performed
196  this->m_Offset += m_SubsampleFactor[0];
197  }
198  return *this;
199  }
201 
209  Self & operator --()
210  {
211  // On the contrary to itk::ImageRegionConstIterator, m_Offset
212  // is not decremented here (it may become negative!)
213  if (this->m_Offset < this->m_SpanBeginOffset + m_SubsampleFactor[0])
214  {
215  this->Decrement();
216  }
217  else
218  {
219  // Now we can
220  this->m_Offset -= m_SubsampleFactor[0];
221  }
222  return *this;
223  }
225 
229  void SetOffset(const OffsetType& offset);
231  {
232  return this->m_Offset;
233  }
235 
239  RegionType GenerateOutputInformation() const;
240 
241 protected:
243  unsigned long m_SubSampledBeginOffset;
244  //unsigned long m_SubSampledReverseEndOffset;
248 
249 private:
250  void Increment(); // jump in a direction other than the fastest moving
251  void Decrement(); // go back in a direction other than the fastest moving
252 };
253 
254 } // end of namespace otb
255 
256 #ifndef OTB_MANUAL_INSTANTIATION
258 #endif
259 
260 #endif
PixelContainer::Pointer PixelContainerPointer
itk::ImageRegionConstIterator< TImage > Superclass
Regular subsample iterator over an image.
TImage::AccessorType AccessorType
itk::Index< Monteverdi_DIMENSION > IndexType
Definition: mvdTypes.h:133
TImage::InternalPixelType InternalPixelType
Superclass::IndexType IndexType
TImage::IndexType IndexType
TImage::PixelType PixelType
TImage::RegionType RegionType
TImage::PixelContainer PixelContainer
TImage::OffsetType OffsetType
TImage::SizeType SizeType