go home Home | Main Page | Topics | 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 "elxDefaultConstruct.h"
24#include <optional>
25
26namespace itk
27{
28
37
38template <typename TInputImage>
39class ITK_TEMPLATE_EXPORT ImageRandomSamplerBase : public ImageSamplerBase<TInputImage>
40{
41public:
43
47 using Pointer = SmartPointer<Self>;
48 using ConstPointer = SmartPointer<const Self>;
49
51 itkNewMacro(Self);
52
55
57 using typename Superclass::DataObjectPointer;
60 using typename Superclass::InputImageType;
61 using typename Superclass::InputImagePointer;
65 using typename Superclass::ImageSampleType;
68 using typename Superclass::MaskType;
69
70 using SeedIntegerType = Statistics::MersenneTwisterRandomVariateGenerator::IntegerType;
71
74 void
75 SetOptionalSeed(const std::optional<SeedIntegerType> arg)
76 {
77 if (arg != m_OptionalSeed)
78 {
79 m_OptionalSeed = arg;
80 this->Modified();
81 }
82 }
83
85 void
87 {
88 SetOptionalSeed(std::make_optional(arg));
89 }
90
92 [[nodiscard]] std::optional<SeedIntegerType>
94 {
95 return m_OptionalSeed;
96 }
97
98 void
99 SetRandomVariateGenerator(Statistics::MersenneTwisterRandomVariateGenerator & randomVariateGenerator)
100 {
101 m_RandomVariateGenerator = &randomVariateGenerator;
102 }
103
104
106 itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension);
107
108protected:
111
113 ~ImageRandomSamplerBase() override = default;
114
116 void
118
119 Statistics::MersenneTwisterRandomVariateGenerator &
124
126 void
127 PrintSelf(std::ostream & os, Indent indent) const override;
128
130 std::vector<double> m_RandomNumberList{};
131
132private:
133 std::optional<SeedIntegerType> m_OptionalSeed{};
134 SeedIntegerType m_Seed{ 121212 + 1 };
135
137 Statistics::MersenneTwisterRandomVariateGenerator * m_RandomVariateGenerator{ &m_DefaultRandomVariateGenerator };
138};
139
140} // end namespace itk
141
142#ifndef ITK_MANUAL_INSTANTIATION
143# include "itkImageRandomSamplerBase.hxx"
144#endif
145
146#endif // end #ifndef itkImageRandomSamplerBase_h
Statistics::MersenneTwisterRandomVariateGenerator * m_RandomVariateGenerator
itkOverrideGetNameOfClassMacro(ImageRandomSamplerBase)
ImageSamplerBase< TInputImage > Superclass
void PrintSelf(std::ostream &os, Indent indent) const override
Statistics::MersenneTwisterRandomVariateGenerator & GetRandomVariateGenerator()
~ImageRandomSamplerBase() override=default
std::optional< SeedIntegerType > GetOptionalSeed() const
Statistics::MersenneTwisterRandomVariateGenerator::IntegerType SeedIntegerType
itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension)
elx::DefaultConstruct< Statistics::MersenneTwisterRandomVariateGenerator > m_DefaultRandomVariateGenerator
SmartPointer< const Self > ConstPointer
ITK_DISALLOW_COPY_AND_MOVE(ImageRandomSamplerBase)
void SetRandomVariateGenerator(Statistics::MersenneTwisterRandomVariateGenerator &randomVariateGenerator)
void SetSeed(const SeedIntegerType arg)
void SetOptionalSeed(const std::optional< SeedIntegerType > arg)
VectorDataContainer< ImageSampleType > ImageSampleContainerType
typename InputImageType::ConstPointer InputImageConstPointer
ImageSample< InputImageType > ImageSampleType
VectorDataContainer< ImageSample< FixedImageType > > OutputVectorContainerType
typename OutputVectorContainerType::Pointer OutputVectorContainerPointer
typename InputImageType::RegionType InputImageRegionType
typename ImageSampleContainerType::Pointer ImageSampleContainerPointer
typename InputImageType::Pointer InputImagePointer
ImageMaskSpatialObject< Self::InputImageDimension > MaskType
typename InputImageType::PixelType InputImagePixelType


Generated on 26-02-2026 for elastix by doxygen 1.16.1 (669aeeefca743c148e2d935b3d3c69535c7491e6) elastix logo