ITK  5.4.0
Insight Toolkit
itkImageRandomConstIteratorWithOnlyIndex.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkImageRandomConstIteratorWithOnlyIndex_h
19 #define itkImageRandomConstIteratorWithOnlyIndex_h
20 
23 
24 namespace itk
25 {
122 template <typename TImage>
124 {
125 public:
129 
131  using typename Superclass::IndexType;
132  using typename Superclass::SizeType;
133  using typename Superclass::OffsetType;
134  using typename Superclass::RegionType;
135  using typename Superclass::ImageType;
136  using typename Superclass::IndexValueType;
137  using typename Superclass::OffsetValueType;
138  using typename Superclass::SizeValueType;
139 
142  ~ImageRandomConstIteratorWithOnlyIndex() override = default;
147  ImageRandomConstIteratorWithOnlyIndex(const ImageType * ptr, const RegionType & region);
148 
156  {
158  }
159 
161  void
163  {
164  this->RandomJump();
165  m_NumberOfSamplesDone = 0L;
166  }
170  void
172  {
173  this->RandomJump();
174  m_NumberOfSamplesDone = m_NumberOfSamplesRequested;
175  }
179  bool
180  IsAtBegin() const
181  {
182  return (m_NumberOfSamplesDone == 0L);
183  }
184 
186  bool
187  IsAtEnd() const
188  {
189  return (m_NumberOfSamplesDone >= m_NumberOfSamplesRequested);
190  }
191 
194  Self &
196  {
197  this->RandomJump();
198  ++m_NumberOfSamplesDone;
199  return *this;
200  }
205  Self &
207  {
208  this->RandomJump();
209  --m_NumberOfSamplesDone;
210  return *this;
211  }
215  void
217  {
218  m_NumberOfSamplesRequested = number;
219  }
220 
223  {
224  return m_NumberOfSamplesRequested;
225  }
226 
228  void
229  ReinitializeSeed();
230 
231  void
232  ReinitializeSeed(int);
233 
234 private:
236  void
237  RandomJump();
238 
241  SizeValueType m_NumberOfSamplesRequested{};
242  SizeValueType m_NumberOfSamplesDone{};
243  SizeValueType m_NumberOfPixelsInRegion{};
244 };
245 } // end namespace itk
246 
247 #ifndef ITK_MANUAL_INSTANTIATION
248 # include "itkImageRandomConstIteratorWithOnlyIndex.hxx"
249 #endif
250 
251 #endif
itk::ImageRandomConstIteratorWithOnlyIndex::IsAtBegin
bool IsAtBegin() const
Definition: itkImageRandomConstIteratorWithOnlyIndex.h:180
itk::ImageRandomConstIteratorWithOnlyIndex::ImageRandomConstIteratorWithOnlyIndex
ImageRandomConstIteratorWithOnlyIndex(const ImageConstIteratorWithOnlyIndex< TImage > &it)
Definition: itkImageRandomConstIteratorWithOnlyIndex.h:155
itk::ImageConstIteratorWithOnlyIndex::OffsetType
typename TImage::OffsetType OffsetType
Definition: itkImageConstIteratorWithOnlyIndex.h:122
itk::ImageRandomConstIteratorWithOnlyIndex::IsAtEnd
bool IsAtEnd() const
Definition: itkImageRandomConstIteratorWithOnlyIndex.h:187
itk::ImageRandomConstIteratorWithOnlyIndex::GetNumberOfSamples
SizeValueType GetNumberOfSamples() const
Definition: itkImageRandomConstIteratorWithOnlyIndex.h:222
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::ImageConstIteratorWithOnlyIndex::RegionType
typename TImage::RegionType RegionType
Definition: itkImageConstIteratorWithOnlyIndex.h:116
itk::IndexValueType
long IndexValueType
Definition: itkIntTypes.h:90
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageRandomConstIteratorWithOnlyIndex::operator--
Self & operator--()
Definition: itkImageRandomConstIteratorWithOnlyIndex.h:206
itk::ImageRandomConstIteratorWithOnlyIndex::SetNumberOfSamples
void SetNumberOfSamples(SizeValueType number)
Definition: itkImageRandomConstIteratorWithOnlyIndex.h:216
itk::ImageConstIteratorWithOnlyIndex::ImageType
TImage ImageType
Definition: itkImageConstIteratorWithOnlyIndex.h:119
itk::ImageRandomConstIteratorWithOnlyIndex::GeneratorPointer
typename Statistics::MersenneTwisterRandomVariateGenerator::Pointer GeneratorPointer
Definition: itkImageRandomConstIteratorWithOnlyIndex.h:239
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ImageConstIteratorWithOnlyIndex::operator=
Self & operator=(const Self &it)
itk::Statistics::MersenneTwisterRandomVariateGenerator::New
static Pointer New()
Method for creation through the object factory.
itkImageConstIteratorWithOnlyIndex.h
itk::OffsetValueType
long OffsetValueType
Definition: itkIntTypes.h:94
itk::ImageConstIteratorWithOnlyIndex
A base class for multi-dimensional iterators templated over image type that are designed to provide o...
Definition: itkImageConstIteratorWithOnlyIndex.h:95
itkMersenneTwisterRandomVariateGenerator.h
itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer
SmartPointer< Self > Pointer
Definition: itkMersenneTwisterRandomVariateGenerator.h:133
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ImageRandomConstIteratorWithOnlyIndex::GoToEnd
void GoToEnd()
Definition: itkImageRandomConstIteratorWithOnlyIndex.h:171
itk::ImageRandomConstIteratorWithOnlyIndex::operator++
Self & operator++()
Definition: itkImageRandomConstIteratorWithOnlyIndex.h:195
itk::ImageRandomConstIteratorWithOnlyIndex::GoToBegin
void GoToBegin()
Definition: itkImageRandomConstIteratorWithOnlyIndex.h:162
itk::ImageConstIteratorWithOnlyIndex::SizeValueType
typename SizeType::SizeValueType SizeValueType
Definition: itkImageConstIteratorWithOnlyIndex.h:113
AddImageFilter
Definition: itkAddImageFilter.h:81
itk::ImageRandomConstIteratorWithOnlyIndex
A multi-dimensional image iterator that visits a random set of locations within an image region,...
Definition: itkImageRandomConstIteratorWithOnlyIndex.h:123
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83