ITK  5.0.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 < typename TSample, typename TRegion >
46  class ITK_TEMPLATE_EXPORT UniformRandomSpatialNeighborSubsampler : public SpatialNeighborSubsampler<TSample, TRegion>
47 {
48 public:
49  ITK_DISALLOW_COPY_AND_ASSIGN(UniformRandomSpatialNeighborSubsampler);
50 
54  using Baseclass = typename Superclass::Baseclass;
57 
60 
62  itkNewMacro(Self);
63 
65  using SampleType = typename Superclass::SampleType;
66  using SampleConstPointer = typename Superclass::SampleConstPointer;
67  using MeasurementVectorType = typename Superclass::MeasurementVectorType;
68  using InstanceIdentifier = typename Superclass::InstanceIdentifier;
69 
70  using SubsampleType = typename Superclass::SubsampleType;
71  using SubsamplePointer = typename Superclass::SubsamplePointer;
72  using SubsampleConstIterator = typename Superclass::SubsampleConstIterator;
73  using InstanceIdentifierHolder = typename Superclass::InstanceIdentifierHolder;
74  using SeedType = typename Baseclass::SeedType;
75 
76  using SearchSizeType = unsigned long;
77  using RandomIntType = unsigned int;
78 
80  using RadiusType = typename Superclass::RadiusType;
82  using IndexType = typename Superclass::IndexType;
84  using SizeType = typename Superclass::SizeType;
85  using ImageHelperType = typename Superclass::ImageHelperType;
86 
87 
90 
91  void SetSeed(const SeedType seed) override
92  {
93  Superclass::SetSeed(seed);
94  this->m_RandomNumberGenerator->SetSeed(this->m_Seed);
95  }
96 
97  virtual void SetUseClockForSeed(const bool& useClock)
98  {
99  if (useClock != this->m_UseClockForSeed)
100  {
101  this->m_UseClockForSeed = useClock;
102  if (this->m_UseClockForSeed)
103  {
104  this->m_RandomNumberGenerator->SetSeed();
105  }
106  this->Modified();
107  }
108  }
109 
110  itkBooleanMacro(UseClockForSeed);
111  itkGetConstMacro(UseClockForSeed, bool);
112 
113  virtual void SetNumberOfResultsRequested(const SearchSizeType& numberRequested)
114  {
115  itkDebugMacro("setting NumberOfResultsRequested to " << numberRequested);
116  if (this->m_RequestMaximumNumberOfResults ||
117  this->m_NumberOfResultsRequested != numberRequested)
118  {
119  this->m_NumberOfResultsRequested = numberRequested;
120  this->m_RequestMaximumNumberOfResults = false;
121  this->Modified();
122  }
123  }
124  itkGetConstMacro(NumberOfResultsRequested, SearchSizeType);
125 
131  void Search(const InstanceIdentifier& query,
132  SubsamplePointer& results) override;
133 
134 protected:
140  typename LightObject::Pointer InternalClone() const override;
141 
143  ~UniformRandomSpatialNeighborSubsampler() override = default;
144 
145  void PrintSelf(std::ostream& os, Indent indent) const override;
146 
151  virtual RandomIntType GetIntegerVariate(RandomIntType lowerBound,
152  RandomIntType upperBound,
153  RandomIntType itkNotUsed(mean));
154 
158 }; // end of class UniformRandomSpatialNeighborSubsampler
159 
160 } // end of namespace Statistics
161 } // end of namespace itk
162 
163 #ifndef ITK_MANUAL_INSTANTIATION
164 #include "itkUniformRandomSpatialNeighborSubsampler.hxx"
165 #endif
166 
167 #endif
typename TSample::InstanceIdentifier InstanceIdentifier
Light weight base class for most itk classes.
This class stores a subset of instance identifiers from another sample object. You can create a subsa...
Definition: itkSubsample.h:41
typename TSample::MeasurementVectorType MeasurementVectorType
A subsampler that uniformly randomly selects points within the specified radius of the query point...
virtual void SetNumberOfResultsRequested(const SearchSizeType &numberRequested)
signed long IndexValueType
Definition: itkIntTypes.h:90
A subsampler that selects all points within the specified radius of the query point.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename SubsampleType::InstanceIdentifierHolder InstanceIdentifierHolder
Fast Index/Offset computation.
typename SubsampleType::ConstIterator SubsampleConstIterator