ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkImageRandomConstIteratorWithIndex.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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 
125  using SizeType = typename Superclass::SizeType;
137 
140  ~ImageRandomConstIteratorWithIndex() override = default;
142 
145  ImageRandomConstIteratorWithIndex(const ImageType *ptr, const RegionType & region);
146 
154  {
156  }
157 
159  void GoToBegin()
160  {
161  this->RandomJump();
162  m_NumberOfSamplesDone = 0L;
163  }
165 
167  void GoToEnd()
168  {
169  this->RandomJump();
170  m_NumberOfSamplesDone = m_NumberOfSamplesRequested;
171  }
173 
175  bool IsAtBegin() const
176  {
177  return ( m_NumberOfSamplesDone == 0L );
178  }
179 
181  bool IsAtEnd() const
182  {
183  return ( m_NumberOfSamplesDone >= m_NumberOfSamplesRequested );
184  }
185 
189  {
190  this->RandomJump();
191  m_NumberOfSamplesDone++;
192  return *this;
193  }
195 
199  {
200  this->RandomJump();
201  m_NumberOfSamplesDone--;
202  return *this;
203  }
205 
207  void SetNumberOfSamples(SizeValueType number);
208 
209  SizeValueType GetNumberOfSamples() const;
210 
212  void ReinitializeSeed();
213 
214  void ReinitializeSeed(int);
215 
216 private:
217  void RandomJump();
218 
224 };
225 } // end namespace itk
226 
227 #ifndef ITK_MANUAL_INSTANTIATION
228 #include "itkImageRandomConstIteratorWithIndex.hxx"
229 #endif
230 
231 #endif
typename SizeType::SizeValueType SizeValueType
typename IndexType::IndexValueType IndexValueType
typename Statistics::MersenneTwisterRandomVariateGenerator::Pointer GeneratorPointer
unsigned long SizeValueType
Definition: itkIntTypes.h:83
typename PixelContainer::Pointer PixelContainerPointer
typename TImage::InternalPixelType InternalPixelType
typename OffsetType::OffsetValueType OffsetValueType
A base class for multi-dimensional iterators templated over image type that are designed to efficient...
signed long IndexValueType
Definition: itkIntTypes.h:90
A multi-dimensional image iterator that visits a random set of pixels within an image region...
ImageRandomConstIteratorWithIndex(const ImageConstIteratorWithIndex< TImage > &it)
typename TImage::PixelContainer PixelContainer
Self & operator=(const Self &it)
signed long OffsetValueType
Definition: itkIntTypes.h:94