go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkImageRandomSamplerBase.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
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 itkImageRandomSamplerBase_h
19#define itkImageRandomSamplerBase_h
20
21#include "itkImageSamplerBase.h"
22#include <itkMersenneTwisterRandomVariateGenerator.h>
23#include <optional>
24
25namespace itk
26{
27
37template <class TInputImage>
38class ITK_TEMPLATE_EXPORT ImageRandomSamplerBase : public ImageSamplerBase<TInputImage>
39{
40public:
42
46 using Pointer = SmartPointer<Self>;
47 using ConstPointer = SmartPointer<const Self>;
48
50 itkNewMacro(Self);
51
54
56 using typename Superclass::DataObjectPointer;
59 using typename Superclass::InputImageType;
60 using typename Superclass::InputImagePointer;
64 using typename Superclass::ImageSampleType;
67 using typename Superclass::MaskType;
68
69 using SeedIntegerType = Statistics::MersenneTwisterRandomVariateGenerator::IntegerType;
70
73 void
74 SetOptionalSeed(const std::optional<SeedIntegerType> arg)
75 {
76 if (arg != m_OptionalSeed)
77 {
78 m_OptionalSeed = arg;
79 this->Modified();
80 }
81 }
82
84 void
86 {
87 SetOptionalSeed(std::make_optional(arg));
88 }
89
91 [[nodiscard]] std::optional<SeedIntegerType>
93 {
94 return m_OptionalSeed;
95 }
96
98 itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension);
99
100protected:
103
105 ~ImageRandomSamplerBase() override = default;
106
108 void
110
112 void
113 PrintSelf(std::ostream & os, Indent indent) const override;
114
116 std::vector<double> m_RandomNumberList{};
117
118private:
119 std::optional<SeedIntegerType> m_OptionalSeed{};
120};
121
122} // end namespace itk
123
124#ifndef ITK_MANUAL_INSTANTIATION
125# include "itkImageRandomSamplerBase.hxx"
126#endif
127
128#endif // end #ifndef itkImageRandomSamplerBase_h
This class is a base class for any image sampler that randomly picks samples.
void PrintSelf(std::ostream &os, Indent indent) const override
~ImageRandomSamplerBase() override=default
std::optional< SeedIntegerType > GetOptionalSeed() const
Statistics::MersenneTwisterRandomVariateGenerator::IntegerType SeedIntegerType
itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension)
SmartPointer< const Self > ConstPointer
ITK_DISALLOW_COPY_AND_MOVE(ImageRandomSamplerBase)
void SetSeed(const SeedIntegerType arg)
void SetOptionalSeed(const std::optional< SeedIntegerType > arg)
A class that defines an image sample, which is the coordinates of a point and its value.
This class is a base class for any image sampler.
typename InputImageType::ConstPointer InputImageConstPointer
typename InputImageType::RegionType InputImageRegionType
typename ImageSampleContainerType::Pointer ImageSampleContainerPointer
typename InputImageType::Pointer InputImagePointer
ImageMaskSpatialObject< Self::InputImageDimension > MaskType
typename InputImageType::PixelType InputImagePixelType
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.


Generated on 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo