ITK  5.2.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  * 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 {
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 
63 
65  itkNewMacro(Self);
66 
68  using SampleType = typename Superclass::SampleType;
69  using SampleConstPointer = typename Superclass::SampleConstPointer;
70  using MeasurementVectorType = typename Superclass::MeasurementVectorType;
71  using InstanceIdentifier = typename Superclass::InstanceIdentifier;
72 
73  using SubsampleType = typename Superclass::SubsampleType;
74  using SubsamplePointer = typename Superclass::SubsamplePointer;
75  using SubsampleConstIterator = typename Superclass::SubsampleConstIterator;
76  using InstanceIdentifierHolder = typename Superclass::InstanceIdentifierHolder;
77  using SeedType = typename Baseclass::SeedType;
78 
79  using SearchSizeType = unsigned long;
80  using RandomIntType = unsigned int;
81 
83  using RadiusType = typename Superclass::RadiusType;
85  using IndexType = typename Superclass::IndexType;
87  using SizeType = typename Superclass::SizeType;
88  using ImageHelperType = 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 
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::Statistics::UniformRandomSpatialNeighborSubsampler::m_RandomNumberGenerator
RandomGeneratorType::Pointer m_RandomNumberGenerator
Definition: itkUniformRandomSpatialNeighborSubsampler.h:162
itk::Statistics::RegionConstrainedSubsampler::SampleType
TSample SampleType
Definition: itkRegionConstrainedSubsampler.h:70
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::SubsampleConstIterator
typename SubsampleType::ConstIterator SubsampleConstIterator
Definition: itkRegionConstrainedSubsampler.h:77
itk::Statistics::RegionConstrainedSubsampler::InstanceIdentifierHolder
typename SubsampleType::InstanceIdentifierHolder InstanceIdentifierHolder
Definition: itkRegionConstrainedSubsampler.h:78
itk::Statistics::RegionConstrainedSubsampler::IndexValueType
typename IndexType::IndexValueType IndexValueType
Definition: itkRegionConstrainedSubsampler.h:83
itk::Statistics::RegionConstrainedSubsampler::MeasurementVectorType
typename TSample::MeasurementVectorType MeasurementVectorType
Definition: itkRegionConstrainedSubsampler.h:72
itk::Statistics::RegionConstrainedSubsampler::Baseclass
typename Superclass::Baseclass Baseclass
Definition: itkRegionConstrainedSubsampler.h:62
itk::Statistics::SpatialNeighborSubsampler::RadiusType
typename RegionType::SizeType RadiusType
Definition: itkSpatialNeighborSubsampler.h:85
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:59
itk::Statistics::RegionConstrainedSubsampler::RegionType
TRegion RegionType
Definition: itkRegionConstrainedSubsampler.h:81
itk::Statistics::RegionConstrainedSubsampler::IndexType
typename RegionType::IndexType IndexType
Definition: itkRegionConstrainedSubsampler.h:82
itk::Statistics::UniformRandomSpatialNeighborSubsampler::SearchSizeType
unsigned long SearchSizeType
Definition: itkUniformRandomSpatialNeighborSubsampler.h:79
itk::Statistics::RegionConstrainedSubsampler::SubsamplePointer
typename SubsampleType::Pointer SubsamplePointer
Definition: itkRegionConstrainedSubsampler.h:76
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::Statistics::Subsample
This class stores a subset of instance identifiers from another sample object. You can create a subsa...
Definition: itkSubsample.h:42
itk::Statistics::UniformRandomSpatialNeighborSubsampler::m_NumberOfResultsRequested
SearchSizeType m_NumberOfResultsRequested
Definition: itkUniformRandomSpatialNeighborSubsampler.h:161
itk::Statistics::RegionConstrainedSubsampler::SampleConstPointer
typename SampleType::ConstPointer SampleConstPointer
Definition: itkRegionConstrainedSubsampler.h:71
itkMersenneTwisterRandomVariateGenerator.h
itk::Statistics::RegionConstrainedSubsampler::SizeType
typename RegionType::SizeType SizeType
Definition: itkRegionConstrainedSubsampler.h:84
itk::ImageHelper
Fast Index/Offset computation.
Definition: itkImageHelper.h:54
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::IndexValueType
signed long IndexValueType
Definition: itkIntTypes.h:90
itk::Statistics::UniformRandomSpatialNeighborSubsampler::m_UseClockForSeed
bool m_UseClockForSeed
Definition: itkUniformRandomSpatialNeighborSubsampler.h:163
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
itk::Statistics::RegionConstrainedSubsampler::InstanceIdentifier
typename TSample::InstanceIdentifier InstanceIdentifier
Definition: itkRegionConstrainedSubsampler.h:73