ITK  6.0.0
Insight Toolkit
itkUniformRandomSpatialNeighborSubsampler.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 itkUniformRandomSpatialNeighborSubsampler_h
19 #define itkUniformRandomSpatialNeighborSubsampler_h
20 
23 
24 namespace itk
25 {
26 namespace Statistics
27 {
48 template <typename TSample, typename TRegion>
49 class ITK_TEMPLATE_EXPORT UniformRandomSpatialNeighborSubsampler : public SpatialNeighborSubsampler<TSample, TRegion>
50 {
51 public:
52  ITK_DISALLOW_COPY_AND_MOVE(UniformRandomSpatialNeighborSubsampler);
53 
57  using Baseclass = typename Superclass::Baseclass;
60 
62  itkOverrideGetNameOfClassMacro(UniformRandomSpatialNeighborSubsampler);
63 
65  itkNewMacro(Self);
66 
68  using typename Superclass::SampleType;
69  using typename Superclass::SampleConstPointer;
70  using typename Superclass::MeasurementVectorType;
71  using typename Superclass::InstanceIdentifier;
72 
73  using typename Superclass::SubsampleType;
74  using typename Superclass::SubsamplePointer;
75  using typename Superclass::SubsampleConstIterator;
76  using typename Superclass::InstanceIdentifierHolder;
77  using SeedType = typename Baseclass::SeedType;
78 
79  using SearchSizeType = unsigned long;
80  using RandomIntType = unsigned int;
81 
83  using typename Superclass::RadiusType;
84  using typename Superclass::RegionType;
85  using typename Superclass::IndexType;
86  using typename Superclass::IndexValueType;
87  using typename Superclass::SizeType;
88  using typename Superclass::ImageHelperType;
89 
90 
93 
94  void
95  SetSeed(const SeedType seed) override
96  {
97  Superclass::SetSeed(seed);
98  this->m_RandomNumberGenerator->SetSeed(this->m_Seed);
99  }
100 
101  virtual void
102  SetUseClockForSeed(const bool & useClock)
103  {
104  if (useClock != this->m_UseClockForSeed)
105  {
106  this->m_UseClockForSeed = useClock;
107  if (this->m_UseClockForSeed)
108  {
109  this->m_RandomNumberGenerator->SetSeed();
110  }
111  this->Modified();
112  }
113  }
114 
115  itkBooleanMacro(UseClockForSeed);
116  itkGetConstMacro(UseClockForSeed, bool);
117 
118  virtual void
120  {
121  itkDebugMacro("setting NumberOfResultsRequested to " << numberRequested);
122  if (this->m_RequestMaximumNumberOfResults || this->m_NumberOfResultsRequested != numberRequested)
123  {
124  this->m_NumberOfResultsRequested = numberRequested;
125  this->m_RequestMaximumNumberOfResults = false;
126  this->Modified();
127  }
128  }
129  itkGetConstMacro(NumberOfResultsRequested, SearchSizeType);
130 
136  void
137  Search(const InstanceIdentifier & query, SubsamplePointer & results) override;
138 
139 protected:
145  typename LightObject::Pointer
146  InternalClone() const override;
147 
149  ~UniformRandomSpatialNeighborSubsampler() override = default;
150 
151  void
152  PrintSelf(std::ostream & os, Indent indent) const override;
153 
158  virtual RandomIntType
159  GetIntegerVariate(RandomIntType lowerBound, RandomIntType upperBound, RandomIntType itkNotUsed(mean));
160 
161  SearchSizeType m_NumberOfResultsRequested{};
162  RandomGeneratorType::Pointer m_RandomNumberGenerator{};
163  bool m_UseClockForSeed{};
164 }; // end of class UniformRandomSpatialNeighborSubsampler
165 
166 } // end of namespace Statistics
167 } // end of namespace itk
168 
169 #ifndef ITK_MANUAL_INSTANTIATION
170 # include "itkUniformRandomSpatialNeighborSubsampler.hxx"
171 #endif
172 
173 #endif
itk::Statistics::UniformRandomSpatialNeighborSubsampler
A subsampler that uniformly randomly selects points within the specified radius of the query point.
Definition: itkUniformRandomSpatialNeighborSubsampler.h:49
itk::Statistics::MersenneTwisterRandomVariateGenerator
MersenneTwisterRandom random variate generator.
Definition: itkMersenneTwisterRandomVariateGenerator.h:127
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::Statistics::UniformRandomSpatialNeighborSubsampler::SetSeed
void SetSeed(const SeedType seed) override
Definition: itkUniformRandomSpatialNeighborSubsampler.h:95
itk::Statistics::SpatialNeighborSubsampler
A subsampler that selects all points within the specified radius of the query point.
Definition: itkSpatialNeighborSubsampler.h:51
itkSpatialNeighborSubsampler.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Statistics::RegionConstrainedSubsampler::Baseclass
typename Superclass::Baseclass Baseclass
Definition: itkRegionConstrainedSubsampler.h:62
itk::IndexValueType
long IndexValueType
Definition: itkIntTypes.h:93
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::Statistics::UniformRandomSpatialNeighborSubsampler::SearchSizeType
unsigned long SearchSizeType
Definition: itkUniformRandomSpatialNeighborSubsampler.h:79
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itkMersenneTwisterRandomVariateGenerator.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::Statistics::UniformRandomSpatialNeighborSubsampler::RandomIntType
unsigned int RandomIntType
Definition: itkUniformRandomSpatialNeighborSubsampler.h:80
itk::Statistics::UniformRandomSpatialNeighborSubsampler::SetUseClockForSeed
virtual void SetUseClockForSeed(const bool &useClock)
Definition: itkUniformRandomSpatialNeighborSubsampler.h:102
itk::Statistics::SubsamplerBase::SeedType
unsigned int SeedType
Definition: itkSubsamplerBase.h:77
itk::Statistics::UniformRandomSpatialNeighborSubsampler::SetNumberOfResultsRequested
virtual void SetNumberOfResultsRequested(const SearchSizeType &numberRequested)
Definition: itkUniformRandomSpatialNeighborSubsampler.h:119