ITK  6.0.0
Insight Toolkit
itkImageRandomConstIteratorWithIndex.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 itkImageRandomConstIteratorWithIndex_h
19 #define itkImageRandomConstIteratorWithIndex_h
20 
23 
24 namespace itk
25 {
115 template <typename TImage>
116 class ITK_TEMPLATE_EXPORT ImageRandomConstIteratorWithIndex : public ImageConstIteratorWithIndex<TImage>
117 {
118 public:
122 
124  using typename Superclass::IndexType;
125  using typename Superclass::SizeType;
126  using typename Superclass::OffsetType;
127  using typename Superclass::RegionType;
128  using typename Superclass::ImageType;
129  using typename Superclass::PixelContainer;
130  using typename Superclass::PixelContainerPointer;
131  using typename Superclass::InternalPixelType;
132  using typename Superclass::PixelType;
133  using typename Superclass::AccessorType;
134  using typename Superclass::IndexValueType;
135  using typename Superclass::OffsetValueType;
136  using typename Superclass::SizeValueType;
137 
140  ~ImageRandomConstIteratorWithIndex() override = default;
145  ImageRandomConstIteratorWithIndex(const ImageType * ptr, const RegionType & region);
146 
154  {
156  }
157 
159  void
161  {
162  this->RandomJump();
163  m_NumberOfSamplesDone = 0L;
164  }
168  void
170  {
171  this->RandomJump();
172  m_NumberOfSamplesDone = m_NumberOfSamplesRequested;
173  }
177  bool
178  IsAtBegin() const
179  {
180  return (m_NumberOfSamplesDone == 0L);
181  }
182 
184  bool
185  IsAtEnd() const
186  {
187  return (m_NumberOfSamplesDone >= m_NumberOfSamplesRequested);
188  }
189 
192  Self &
194  {
195  this->RandomJump();
196  ++m_NumberOfSamplesDone;
197  return *this;
198  }
203  Self &
205  {
206  this->RandomJump();
207  --m_NumberOfSamplesDone;
208  return *this;
209  }
213  void
215  {
216  m_NumberOfSamplesRequested = number;
217  }
218 
221  {
222  return m_NumberOfSamplesRequested;
223  }
224 
226  void
227  ReinitializeSeed();
228 
229  void
230  ReinitializeSeed(int);
231 
232 private:
234  void
235  RandomJump();
236 
239  SizeValueType m_NumberOfSamplesRequested{};
240  SizeValueType m_NumberOfSamplesDone{};
241  SizeValueType m_NumberOfPixelsInRegion{};
242 };
243 } // end namespace itk
244 
245 #ifndef ITK_MANUAL_INSTANTIATION
246 # include "itkImageRandomConstIteratorWithIndex.hxx"
247 #endif
248 
249 #endif
itk::ImageConstIteratorWithIndex::PixelContainerPointer
typename PixelContainer::Pointer PixelContainerPointer
Definition: itkImageConstIteratorWithIndex.h:122
itkImageConstIteratorWithIndex.h
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::ImageRandomConstIteratorWithIndex::ImageRandomConstIteratorWithIndex
ImageRandomConstIteratorWithIndex(const ImageConstIteratorWithIndex< TImage > &it)
Definition: itkImageRandomConstIteratorWithIndex.h:153
itk::ImageConstIteratorWithIndex::PixelType
typename TImage::PixelType PixelType
Definition: itkImageConstIteratorWithIndex.h:128
itk::ImageRandomConstIteratorWithIndex::IsAtEnd
bool IsAtEnd() const
Definition: itkImageRandomConstIteratorWithIndex.h:185
itk::IndexValueType
long IndexValueType
Definition: itkIntTypes.h:93
itk::ImageConstIteratorWithIndex::InternalPixelType
typename TImage::InternalPixelType InternalPixelType
Definition: itkImageConstIteratorWithIndex.h:125
itk::ImageRandomConstIteratorWithIndex::operator++
Self & operator++()
Definition: itkImageRandomConstIteratorWithIndex.h:193
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageRandomConstIteratorWithIndex::operator--
Self & operator--()
Definition: itkImageRandomConstIteratorWithIndex.h:204
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ImageRandomConstIteratorWithIndex::IsAtBegin
bool IsAtBegin() const
Definition: itkImageRandomConstIteratorWithIndex.h:178
itk::ImageConstIteratorWithIndex::AccessorType
typename TImage::AccessorType AccessorType
Definition: itkImageConstIteratorWithIndex.h:132
itk::Statistics::MersenneTwisterRandomVariateGenerator::New
static Pointer New()
Method for creation through the object factory.
itk::ImageRandomConstIteratorWithIndex::SetNumberOfSamples
void SetNumberOfSamples(SizeValueType number)
Definition: itkImageRandomConstIteratorWithIndex.h:214
itk::ImageRandomConstIteratorWithIndex::GoToEnd
void GoToEnd()
Definition: itkImageRandomConstIteratorWithIndex.h:169
itk::ImageConstIteratorWithIndex
A base class for multi-dimensional iterators templated over image type that are designed to efficient...
Definition: itkImageConstIteratorWithIndex.h:92
itk::OffsetValueType
long OffsetValueType
Definition: itkIntTypes.h:97
itkMersenneTwisterRandomVariateGenerator.h
itk::ImageRandomConstIteratorWithIndex::GoToBegin
void GoToBegin()
Definition: itkImageRandomConstIteratorWithIndex.h:160
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: itkAnatomicalOrientation.h:29
itk::ImageRandomConstIteratorWithIndex::GetNumberOfSamples
SizeValueType GetNumberOfSamples() const
Definition: itkImageRandomConstIteratorWithIndex.h:220
itk::ImageConstIteratorWithIndex::RegionType
typename TImage::RegionType RegionType
Definition: itkImageConstIteratorWithIndex.h:113
itk::ImageRandomConstIteratorWithIndex::GeneratorPointer
typename Statistics::MersenneTwisterRandomVariateGenerator::Pointer GeneratorPointer
Definition: itkImageRandomConstIteratorWithIndex.h:237
AddImageFilter
Definition: itkAddImageFilter.h:81
itk::ImageConstIteratorWithIndex::ImageType
TImage ImageType
Definition: itkImageConstIteratorWithIndex.h:116
itk::ImageConstIteratorWithIndex::PixelContainer
typename TImage::PixelContainer PixelContainer
Definition: itkImageConstIteratorWithIndex.h:121
itk::ImageConstIteratorWithIndex::SizeValueType
typename SizeType::SizeValueType SizeValueType
Definition: itkImageConstIteratorWithIndex.h:110
itk::ImageConstIteratorWithIndex::operator=
Self & operator=(const Self &it)
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::ImageRandomConstIteratorWithIndex
A multi-dimensional image iterator that visits a random set of pixels within an image region.
Definition: itkImageRandomConstIteratorWithIndex.h:116
itk::ImageConstIteratorWithIndex::OffsetType
typename TImage::OffsetType OffsetType
Definition: itkImageConstIteratorWithIndex.h:136