00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkImageRandomConstIteratorWithIndex_h
00018 #define __itkImageRandomConstIteratorWithIndex_h
00019
00020 #include "itkImageConstIteratorWithIndex.h"
00021 #include "itkMersenneTwisterRandomVariateGenerator.h"
00022
00023 namespace itk
00024 {
00025
00112 template<typename TImage>
00113 class ITK_EXPORT ImageRandomConstIteratorWithIndex : public ImageConstIteratorWithIndex<TImage>
00114 {
00115 public:
00117 typedef ImageRandomConstIteratorWithIndex Self;
00118 typedef ImageConstIteratorWithIndex<TImage> Superclass;
00119
00124 typedef typename TImage::IndexType IndexType;
00125
00130 typedef typename TImage::RegionType RegionType;
00131
00136 typedef TImage ImageType;
00137
00141 typedef typename TImage::PixelContainer PixelContainer;
00142 typedef typename PixelContainer::Pointer PixelContainerPointer;
00143
00145 ImageRandomConstIteratorWithIndex();
00146 ~ImageRandomConstIteratorWithIndex() {};
00147
00150 ImageRandomConstIteratorWithIndex(const ImageType *ptr, const RegionType& region);
00151
00158 ImageRandomConstIteratorWithIndex( const ImageConstIteratorWithIndex<TImage> &it)
00159 { this->ImageConstIteratorWithIndex<TImage>::operator=(it); }
00160
00162 void GoToBegin(void)
00163 {
00164 this->RandomJump();
00165 m_NumberOfSamplesDone = 0L;
00166 }
00167
00169 void GoToEnd(void)
00170 {
00171 this->RandomJump();
00172 m_NumberOfSamplesDone = m_NumberOfSamplesRequested;
00173 }
00174
00176 bool IsAtBegin(void) const
00177 { return (m_NumberOfSamplesDone == 0L) ; }
00178
00180 bool IsAtEnd(void) const
00181 { return (m_NumberOfSamplesDone >= m_NumberOfSamplesRequested); }
00182
00185 Self & operator++()
00186 {
00187 this->RandomJump();
00188 m_NumberOfSamplesDone++;
00189 return *this;
00190 }
00191
00194 Self & operator--()
00195 {
00196 this->RandomJump();
00197 m_NumberOfSamplesDone--;
00198 return *this;
00199 }
00200
00202 void SetNumberOfSamples( unsigned long number );
00203 unsigned long GetNumberOfSamples( void ) const;
00204
00206 void ReinitializeSeed();
00207 void ReinitializeSeed(int);
00208
00209 private:
00210 void RandomJump();
00211 Statistics::MersenneTwisterRandomVariateGenerator::Pointer m_Generator;
00212 unsigned long m_NumberOfSamplesRequested;
00213 unsigned long m_NumberOfSamplesDone;
00214 unsigned long m_NumberOfPixelsInRegion;
00215 };
00216
00217 }
00218
00219 #ifndef ITK_MANUAL_INSTANTIATION
00220 #include "itkImageRandomConstIteratorWithIndex.txx"
00221 #endif
00222
00223 #endif
00224
00225
00226