ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkUniformRandomSpatialNeighborSubsampler.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 __itkUniformRandomSpatialNeighborSubsampler_h
19 #define __itkUniformRandomSpatialNeighborSubsampler_h
20 
23 
24 namespace itk {
25 namespace Statistics {
45 template < class TSample, class TRegion >
46  class ITK_EXPORT UniformRandomSpatialNeighborSubsampler : public SpatialNeighborSubsampler<TSample, TRegion>
47 {
48 public:
52  typedef typename Superclass::Baseclass Baseclass;
55 
58 
60  itkNewMacro(Self);
61 
63  typedef typename Superclass::SampleType SampleType;
64  typedef typename Superclass::SampleConstPointer SampleConstPointer;
65  typedef typename Superclass::MeasurementVectorType MeasurementVectorType;
66  typedef typename Superclass::InstanceIdentifier InstanceIdentifier;
67 
68  typedef typename Superclass::SubsampleType SubsampleType;
69  typedef typename Superclass::SubsamplePointer SubsamplePointer;
70  typedef typename Superclass::SubsampleConstIterator SubsampleConstIterator;
71  typedef typename Superclass::InstanceIdentifierHolder InstanceIdentifierHolder;
72  typedef typename Baseclass::SeedType SeedType;
73 
74  typedef unsigned long SearchSizeType;
75  typedef unsigned int RandomIntType;
76 
78  typedef typename Superclass::RadiusType RadiusType;
79  typedef typename Superclass::RegionType RegionType;
80  typedef typename Superclass::IndexType IndexType;
82  typedef typename Superclass::SizeType SizeType;
83  typedef typename Superclass::ImageHelperType ImageHelperType;
84 
85 
88 
89  virtual void SetSeed(const SeedType seed)
90  {
91  Superclass::SetSeed(seed);
92  this->m_RandomNumberGenerator->SetSeed(this->m_Seed);
93  }
94 
95  virtual void SetUseClockForSeed(const bool& useClock)
96  {
97  if (useClock != this->m_UseClockForSeed)
98  {
99  this->m_UseClockForSeed = useClock;
100  if (this->m_UseClockForSeed)
101  {
102  this->m_RandomNumberGenerator->SetSeed();
103  }
104  this->Modified();
105  }
106  }
107 
108  itkBooleanMacro(UseClockForSeed);
109  itkGetConstMacro(UseClockForSeed, bool);
110 
111  virtual void SetNumberOfResultsRequested(const SearchSizeType& numberRequested)
112  {
113  itkDebugMacro("setting NumberOfResultsRequested to " << numberRequested);
114  if (this->m_RequestMaximumNumberOfResults ||
115  this->m_NumberOfResultsRequested != numberRequested)
116  {
117  this->m_NumberOfResultsRequested = numberRequested;
118  this->m_RequestMaximumNumberOfResults = false;
119  this->Modified();
120  }
121  }
122  itkGetConstMacro(NumberOfResultsRequested, SearchSizeType);
123 
129  virtual void Search(const InstanceIdentifier& query,
130  SubsamplePointer& results);
131 
132 protected:
138  virtual typename LightObject::Pointer InternalClone() const;
139 
142 
143  virtual void PrintSelf(std::ostream& os, Indent indent) const;
144 
149  virtual RandomIntType GetIntegerVariate(RandomIntType lowerBound,
150  RandomIntType upperBound,
151  RandomIntType itkNotUsed(mean));
152 
156 
157 private:
158  UniformRandomSpatialNeighborSubsampler(const Self&); // purposely not implemented
159  void operator=(const Self&); // purposely not implemented
160 
161 }; // end of class UniformRandomSpatialNeighborSubsampler
162 
163 } // end of namespace Statistics
164 } // end of namespace itk
165 
166 #ifndef ITK_MANUAL_INSTANTIATION
167 #include "itkUniformRandomSpatialNeighborSubsampler.hxx"
168 #endif
169 
170 #endif
171