ITK  5.1.0
Insight 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 {
26 namespace Statistics
27 {
47 template <typename TSample, typename TRegion>
48 class ITK_TEMPLATE_EXPORT UniformRandomSpatialNeighborSubsampler : public SpatialNeighborSubsampler<TSample, TRegion>
49 {
50 public:
51  ITK_DISALLOW_COPY_AND_ASSIGN(UniformRandomSpatialNeighborSubsampler);
52 
56  using Baseclass = typename Superclass::Baseclass;
59 
62 
64  itkNewMacro(Self);
65 
67  using SampleType = typename Superclass::SampleType;
68  using SampleConstPointer = typename Superclass::SampleConstPointer;
69  using MeasurementVectorType = typename Superclass::MeasurementVectorType;
70  using InstanceIdentifier = typename Superclass::InstanceIdentifier;
71 
72  using SubsampleType = typename Superclass::SubsampleType;
73  using SubsamplePointer = typename Superclass::SubsamplePointer;
74  using SubsampleConstIterator = typename Superclass::SubsampleConstIterator;
75  using InstanceIdentifierHolder = typename Superclass::InstanceIdentifierHolder;
76  using SeedType = typename Baseclass::SeedType;
77 
78  using SearchSizeType = unsigned long;
79  using RandomIntType = unsigned int;
80 
82  using RadiusType = typename Superclass::RadiusType;
84  using IndexType = typename Superclass::IndexType;
86  using SizeType = typename Superclass::SizeType;
87  using ImageHelperType = typename Superclass::ImageHelperType;
88 
89 
92 
93  void
94  SetSeed(const SeedType seed) override
95  {
96  Superclass::SetSeed(seed);
97  this->m_RandomNumberGenerator->SetSeed(this->m_Seed);
98  }
99 
100  virtual void
101  SetUseClockForSeed(const bool & useClock)
102  {
103  if (useClock != this->m_UseClockForSeed)
104  {
105  this->m_UseClockForSeed = useClock;
106  if (this->m_UseClockForSeed)
107  {
108  this->m_RandomNumberGenerator->SetSeed();
109  }
110  this->Modified();
111  }
112  }
113 
114  itkBooleanMacro(UseClockForSeed);
115  itkGetConstMacro(UseClockForSeed, bool);
116 
117  virtual void
119  {
120  itkDebugMacro("setting NumberOfResultsRequested to " << numberRequested);
121  if (this->m_RequestMaximumNumberOfResults || this->m_NumberOfResultsRequested != numberRequested)
122  {
123  this->m_NumberOfResultsRequested = numberRequested;
124  this->m_RequestMaximumNumberOfResults = false;
125  this->Modified();
126  }
127  }
128  itkGetConstMacro(NumberOfResultsRequested, SearchSizeType);
129 
135  void
136  Search(const InstanceIdentifier & query, SubsamplePointer & results) override;
137 
138 protected:
144  typename LightObject::Pointer
145  InternalClone() const override;
146 
148  ~UniformRandomSpatialNeighborSubsampler() override = default;
149 
150  void
151  PrintSelf(std::ostream & os, Indent indent) const override;
152 
157  virtual RandomIntType
158  GetIntegerVariate(RandomIntType lowerBound, RandomIntType upperBound, RandomIntType itkNotUsed(mean));
159 
163 }; // end of class UniformRandomSpatialNeighborSubsampler
164 
165 } // end of namespace Statistics
166 } // end of namespace itk
167 
168 #ifndef ITK_MANUAL_INSTANTIATION
169 # include "itkUniformRandomSpatialNeighborSubsampler.hxx"
170 #endif
171 
172 #endif
itk::Statistics::UniformRandomSpatialNeighborSubsampler
A subsampler that uniformly randomly selects points within the specified radius of the query point.
Definition: itkUniformRandomSpatialNeighborSubsampler.h:48
itk::Statistics::MersenneTwisterRandomVariateGenerator
MersenneTwisterRandom random variate generator.
Definition: itkMersenneTwisterRandomVariateGenerator.h:127
itk::Statistics::UniformRandomSpatialNeighborSubsampler::m_RandomNumberGenerator
RandomGeneratorType::Pointer m_RandomNumberGenerator
Definition: itkUniformRandomSpatialNeighborSubsampler.h:161
itk::Statistics::RegionConstrainedSubsampler::SampleType
TSample SampleType
Definition: itkRegionConstrainedSubsampler.h:69
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:94
itk::Statistics::SpatialNeighborSubsampler
A subsampler that selects all points within the specified radius of the query point.
Definition: itkSpatialNeighborSubsampler.h:50
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:76
itk::Statistics::RegionConstrainedSubsampler::InstanceIdentifierHolder
typename SubsampleType::InstanceIdentifierHolder InstanceIdentifierHolder
Definition: itkRegionConstrainedSubsampler.h:77
itk::Statistics::RegionConstrainedSubsampler::IndexValueType
typename IndexType::IndexValueType IndexValueType
Definition: itkRegionConstrainedSubsampler.h:82
itk::Statistics::RegionConstrainedSubsampler::MeasurementVectorType
typename TSample::MeasurementVectorType MeasurementVectorType
Definition: itkRegionConstrainedSubsampler.h:71
itk::Statistics::RegionConstrainedSubsampler::Baseclass
typename Superclass::Baseclass Baseclass
Definition: itkRegionConstrainedSubsampler.h:61
itk::Statistics::SpatialNeighborSubsampler::RadiusType
typename RegionType::SizeType RadiusType
Definition: itkSpatialNeighborSubsampler.h:84
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:80
itk::Statistics::RegionConstrainedSubsampler::IndexType
typename RegionType::IndexType IndexType
Definition: itkRegionConstrainedSubsampler.h:81
itk::Statistics::UniformRandomSpatialNeighborSubsampler::SearchSizeType
unsigned long SearchSizeType
Definition: itkUniformRandomSpatialNeighborSubsampler.h:78
itk::Statistics::RegionConstrainedSubsampler::SubsamplePointer
typename SubsampleType::Pointer SubsamplePointer
Definition: itkRegionConstrainedSubsampler.h:75
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:41
itk::Statistics::UniformRandomSpatialNeighborSubsampler::m_NumberOfResultsRequested
SearchSizeType m_NumberOfResultsRequested
Definition: itkUniformRandomSpatialNeighborSubsampler.h:160
itk::Statistics::RegionConstrainedSubsampler::SampleConstPointer
typename SampleType::ConstPointer SampleConstPointer
Definition: itkRegionConstrainedSubsampler.h:70
itkMersenneTwisterRandomVariateGenerator.h
itk::Statistics::RegionConstrainedSubsampler::SizeType
typename RegionType::SizeType SizeType
Definition: itkRegionConstrainedSubsampler.h:83
itk::ImageHelper
Fast Index/Offset computation.
Definition: itkImageHelper.h:54
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::IndexValueType
signed long IndexValueType
Definition: itkIntTypes.h:90
itk::Statistics::UniformRandomSpatialNeighborSubsampler::m_UseClockForSeed
bool m_UseClockForSeed
Definition: itkUniformRandomSpatialNeighborSubsampler.h:162
itk::Statistics::UniformRandomSpatialNeighborSubsampler::RandomIntType
unsigned int RandomIntType
Definition: itkUniformRandomSpatialNeighborSubsampler.h:79
itk::Statistics::UniformRandomSpatialNeighborSubsampler::SetUseClockForSeed
virtual void SetUseClockForSeed(const bool &useClock)
Definition: itkUniformRandomSpatialNeighborSubsampler.h:101
itk::Statistics::SubsamplerBase::SeedType
unsigned int SeedType
Definition: itkSubsamplerBase.h:76
itk::Statistics::UniformRandomSpatialNeighborSubsampler::SetNumberOfResultsRequested
virtual void SetNumberOfResultsRequested(const SearchSizeType &numberRequested)
Definition: itkUniformRandomSpatialNeighborSubsampler.h:118
itk::Statistics::RegionConstrainedSubsampler::InstanceIdentifier
typename TSample::InstanceIdentifier InstanceIdentifier
Definition: itkRegionConstrainedSubsampler.h:72