OTB  9.0.0
Orfeo Toolbox
otbSubsampledImageRegionConstIterator.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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 
26 #include "itkImageRegionConstIterator.h"
27 
28 namespace otb
29 {
30 
43 template <class TImage>
44 class ITK_EXPORT SubsampledImageRegionConstIterator : public itk::ImageRegionConstIterator<TImage>
45 {
46 public:
47 
50  typedef itk::ImageRegionConstIterator<TImage> Superclass;
51 
53  itkTypeMacro(SubsampledImageRegionConstIterator, ImageRegionConstIterator);
54 
59  itkStaticConstMacro(ImageIteratorDimension, unsigned int, Superclass::ImageIteratorDimension);
60 
63  typedef typename Superclass::IndexType IndexType;
64 
67  typedef typename Superclass::SizeType SizeType;
68 
70  typedef typename Superclass::RegionType RegionType;
71 
74  typedef typename Superclass::ImageType ImageType;
75 
78  // typedef typename Superclass::OffsetType OffsetType;
79  typedef unsigned long OffsetType;
80 
84  typedef typename Superclass::PixelContainer PixelContainer;
85  typedef typename Superclass::PixelContainerPointer PixelContainerPointer;
86 
88  typedef typename Superclass::InternalPixelType InternalPixelType;
89 
91  typedef typename Superclass::PixelType PixelType;
92 
95  typedef typename Superclass::AccessorType AccessorType;
96 
98  // typedef typename Superclass::IndexValueType IndexValueType;
99  typedef typename IndexType::IndexValueType IndexValueType;
100 
103 
106  SubsampledImageRegionConstIterator(const ImageType* ptr, const RegionType& region);
107 
114  SubsampledImageRegionConstIterator(const itk::ImageIterator<TImage>& it);
115 
122  SubsampledImageRegionConstIterator(const itk::ImageConstIterator<TImage>& it);
123 
125  void SetSubsampleFactor(IndexValueType factor);
126 
128  void SetSubsampleFactor(const IndexType& factor);
129 
131  {
132  return this->m_SubsampleFactor;
133  }
134 
137  void GoToBegin();
138 
141  void GoToEnd();
142 
149  bool IsAtBegin(void) const
150  {
151  return (this->m_Offset <= m_SubSampledBeginOffset);
152  }
153 
161  bool IsAtEnd(void) const
162  {
163  return (this->m_Offset >= m_SubSampledEndOffset);
164  }
165 
169  void SetIndex(const IndexType& ind) override;
170 
173  {
174  return Superclass::GetIndex();
175  }
176 
185  {
186  // On the contrary to itk::ImageRegionConstIterator, m_Offset to
187  // not incremented before the test
188  if (this->m_Offset + m_SubsampleFactor[0] >= this->m_SpanEndOffset)
189  {
190  this->Increment();
191  }
192  else
193  {
194  // Now, the increment is performed
195  this->m_Offset += m_SubsampleFactor[0];
196  }
197  return *this;
198  }
200 
209  {
210  // On the contrary to itk::ImageRegionConstIterator, m_Offset
211  // is not decremented here (it may become negative!)
212  if (this->m_Offset < this->m_SpanBeginOffset + m_SubsampleFactor[0])
213  {
214  this->Decrement();
215  }
216  else
217  {
218  // Now we can
219  this->m_Offset -= m_SubsampleFactor[0];
220  }
221  return *this;
222  }
224 
228  void SetOffset(const OffsetType& offset);
230  {
231  return this->m_Offset;
232  }
234 
238  RegionType GenerateOutputInformation() const;
239 
240 protected:
242  unsigned long m_SubSampledBeginOffset;
243  // unsigned long m_SubSampledReverseEndOffset;
247 
248 private:
249  void Increment(); // jump in a direction other than the fastest moving
250  void Decrement(); // go back in a direction other than the fastest moving
251 };
252 
253 } // end of namespace otb
254 
255 #ifndef OTB_MANUAL_INSTANTIATION
257 #endif
258 
259 #endif
otb::SubsampledImageRegionConstIterator::ImageType
Superclass::ImageType ImageType
Definition: otbSubsampledImageRegionConstIterator.h:74
otb::SubsampledImageRegionConstIterator::m_LastUsableIndex
IndexType m_LastUsableIndex
Definition: otbSubsampledImageRegionConstIterator.h:246
otb::SubsampledImageRegionConstIterator::PixelType
Superclass::PixelType PixelType
Definition: otbSubsampledImageRegionConstIterator.h:91
otb::SubsampledImageRegionConstIterator::GetSubsampleFactor
const IndexType & GetSubsampleFactor() const
Definition: otbSubsampledImageRegionConstIterator.h:130
otb::SubsampledImageRegionConstIterator::RegionType
Superclass::RegionType RegionType
Definition: otbSubsampledImageRegionConstIterator.h:70
otbSubsampledImageRegionConstIterator.hxx
otb::SubsampledImageRegionConstIterator::m_SubSampledEndOffset
long m_SubSampledEndOffset
Definition: otbSubsampledImageRegionConstIterator.h:244
otb::SubsampledImageRegionConstIterator::InternalPixelType
Superclass::InternalPixelType InternalPixelType
Definition: otbSubsampledImageRegionConstIterator.h:88
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::SubsampledImageRegionConstIterator::IndexType
Superclass::IndexType IndexType
Definition: otbSubsampledImageRegionConstIterator.h:63
otb::SubsampledImageRegionConstIterator::GetOffset
OffsetType GetOffset() const
Definition: otbSubsampledImageRegionConstIterator.h:229
otb::SubsampledImageRegionConstIterator::operator++
Self & operator++()
Definition: otbSubsampledImageRegionConstIterator.h:184
otb::SubsampledImageRegionConstIterator::IsAtBegin
bool IsAtBegin(void) const
Definition: otbSubsampledImageRegionConstIterator.h:149
otb::SubsampledImageRegionConstIterator::PixelContainer
Superclass::PixelContainer PixelContainer
Definition: otbSubsampledImageRegionConstIterator.h:84
otb::SubsampledImageRegionConstIterator::m_SubSampledBeginOffset
unsigned long m_SubSampledBeginOffset
Definition: otbSubsampledImageRegionConstIterator.h:242
otb::SubsampledImageRegionConstIterator::Self
SubsampledImageRegionConstIterator Self
Definition: otbSubsampledImageRegionConstIterator.h:49
otb::SubsampledImageRegionConstIterator::GetIndex
IndexType GetIndex() const
Definition: otbSubsampledImageRegionConstIterator.h:172
otb::SubsampledImageRegionConstIterator::m_SubsampleFactor
IndexType m_SubsampleFactor
Definition: otbSubsampledImageRegionConstIterator.h:241
otb::SubsampledImageRegionConstIterator::operator--
Self & operator--()
Definition: otbSubsampledImageRegionConstIterator.h:208
otb::SubsampledImageRegionConstIterator::IsAtEnd
bool IsAtEnd(void) const
Definition: otbSubsampledImageRegionConstIterator.h:161
otb::SubsampledImageRegionConstIterator::m_FirstUsableIndex
IndexType m_FirstUsableIndex
Definition: otbSubsampledImageRegionConstIterator.h:245
otb::SubsampledImageRegionConstIterator
Regular subsample iterator over an image.
Definition: otbSubsampledImageRegionConstIterator.h:44
otb::SubsampledImageRegionConstIterator::PixelContainerPointer
Superclass::PixelContainerPointer PixelContainerPointer
Definition: otbSubsampledImageRegionConstIterator.h:85
otb::SubsampledImageRegionConstIterator::OffsetType
unsigned long OffsetType
Definition: otbSubsampledImageRegionConstIterator.h:79
otb::SubsampledImageRegionConstIterator::Superclass
itk::ImageRegionConstIterator< TImage > Superclass
Definition: otbSubsampledImageRegionConstIterator.h:50
otb::SubsampledImageRegionConstIterator::AccessorType
Superclass::AccessorType AccessorType
Definition: otbSubsampledImageRegionConstIterator.h:95
otb::SubsampledImageRegionConstIterator::SizeType
Superclass::SizeType SizeType
Definition: otbSubsampledImageRegionConstIterator.h:67
otb::SubsampledImageRegionConstIterator::IndexValueType
IndexType::IndexValueType IndexValueType
Definition: otbSubsampledImageRegionConstIterator.h:99