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() {};
00148
00151 ImageRandomConstIteratorWithIndex(const ImageType *ptr, const RegionType& region);
00152
00159 ImageRandomConstIteratorWithIndex( const ImageConstIteratorWithIndex<TImage> &it)
00160 { this->ImageConstIteratorWithIndex<TImage>::operator=(it); }
00161
00163 void GoToBegin(void)
00164 {
00165 this->RandomJump();
00166 m_NumberOfSamplesDone = 0L;
00167 }
00169
00171 void GoToEnd(void)
00172 {
00173 this->RandomJump();
00174 m_NumberOfSamplesDone = m_NumberOfSamplesRequested;
00175 }
00177
00179 bool IsAtBegin(void) const
00180 { return (m_NumberOfSamplesDone == 0L) ; }
00181
00183 bool IsAtEnd(void) const
00184 { return (m_NumberOfSamplesDone >= m_NumberOfSamplesRequested); }
00185
00188 Self & operator++()
00189 {
00190 this->RandomJump();
00191 m_NumberOfSamplesDone++;
00192 return *this;
00193 }
00195
00198 Self & operator--()
00199 {
00200 this->RandomJump();
00201 m_NumberOfSamplesDone--;
00202 return *this;
00203 }
00205
00207 void SetNumberOfSamples( unsigned long number );
00208 unsigned long GetNumberOfSamples( void ) const;
00210
00212 void ReinitializeSeed();
00213 void ReinitializeSeed(int);
00215
00216 private:
00217 void RandomJump();
00218 Statistics::MersenneTwisterRandomVariateGenerator::Pointer m_Generator;
00219 unsigned long m_NumberOfSamplesRequested;
00220 unsigned long m_NumberOfSamplesDone;
00221 unsigned long m_NumberOfPixelsInRegion;
00222 };
00223
00224 }
00225
00226 #ifndef ITK_MANUAL_INSTANTIATION
00227 #include "itkImageRandomConstIteratorWithIndex.txx"
00228 #endif
00229
00230 #endif
00231
00232
00233
00234