go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkImageRandomCoordinateSampler.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 itkImageRandomCoordinateSampler_h
19#define itkImageRandomCoordinateSampler_h
20
22#include "itkInterpolateImageFunction.h"
23#include "itkBSplineInterpolateImageFunction.h"
24#include "itkMersenneTwisterRandomVariateGenerator.h"
25
26namespace itk
27{
28
39template <class TInputImage>
40class ITK_TEMPLATE_EXPORT ImageRandomCoordinateSampler : public ImageRandomSamplerBase<TInputImage>
41{
42public:
44
48 using Pointer = SmartPointer<Self>;
49 using ConstPointer = SmartPointer<const Self>;
50
52 itkNewMacro(Self);
53
56
58 using typename Superclass::DataObjectPointer;
61 using typename Superclass::InputImageType;
62 using typename Superclass::InputImagePointer;
66 using typename Superclass::ImageSampleType;
69 using typename Superclass::MaskType;
70 using typename Superclass::InputImageSizeType;
71 using InputImageSpacingType = typename InputImageType::SpacingType;
76
78 itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension);
79
83 using InterpolatorType = InterpolateImageFunction<InputImageType, CoordRepType>;
84 using InterpolatorPointer = typename InterpolatorType::Pointer;
85 using DefaultInterpolatorType = BSplineInterpolateImageFunction<InputImageType, CoordRepType, double>;
86
88 using RandomGeneratorType = itk::Statistics::MersenneTwisterRandomVariateGenerator;
89 using RandomGeneratorPointer = typename RandomGeneratorType::Pointer;
90
92 itkSetObjectMacro(Interpolator, InterpolatorType);
94
97 itkSetMacro(SampleRegionSize, InputImageSpacingType);
98 itkGetConstReferenceMacro(SampleRegionSize, InputImageSpacingType);
99
102 itkGetConstMacro(UseRandomSampleRegion, bool);
103 itkSetMacro(UseRandomSampleRegion, bool);
104
105protected:
106 using InputImageContinuousIndexType = typename InterpolatorType::ContinuousIndexType;
107
110
112 ~ImageRandomCoordinateSampler() override = default;
113
115 void
116 PrintSelf(std::ostream & os, Indent indent) const override;
117
119 void
120 GenerateData() override;
121
123 void
125
126 void
127 ThreadedGenerateData(const InputImageRegionType & inputRegionForThread, ThreadIdType threadId) override;
128
130 virtual void
132 const InputImageContinuousIndexType & largestContIndex,
133 InputImageContinuousIndexType & randomContIndex);
134
135 InterpolatorPointer m_Interpolator = [] {
136 const auto interpolator = DefaultInterpolatorType::New();
137 interpolator->SetSplineOrder(3);
138 return interpolator;
139 }();
140
141 RandomGeneratorPointer m_RandomGenerator{ RandomGeneratorType::GetInstance() };
142 InputImageSpacingType m_SampleRegionSize{ itk::MakeFilled<InputImageSpacingType>(1.0) };
143
149 virtual void
151 const InputImageContinuousIndexType & largestImageContIndex,
152 InputImageContinuousIndexType & smallestContIndex,
153 InputImageContinuousIndexType & largestContIndex);
154
155private:
156 bool m_UseRandomSampleRegion{ false };
157};
158
159} // end namespace itk
160
161#ifndef ITK_MANUAL_INSTANTIATION
162# include "itkImageRandomCoordinateSampler.hxx"
163#endif
164
165#endif // end #ifndef itkImageRandomCoordinateSampler_h
Samples an image by randomly composing a set of physical coordinates.
typename InterpolatorType::Pointer InterpolatorPointer
BSplineInterpolateImageFunction< InputImageType, CoordRepType, double > DefaultInterpolatorType
typename InterpolatorType::ContinuousIndexType InputImageContinuousIndexType
virtual void GenerateSampleRegion(const InputImageContinuousIndexType &smallestImageContIndex, const InputImageContinuousIndexType &largestImageContIndex, InputImageContinuousIndexType &smallestContIndex, InputImageContinuousIndexType &largestContIndex)
void PrintSelf(std::ostream &os, Indent indent) const override
void ThreadedGenerateData(const InputImageRegionType &inputRegionForThread, ThreadIdType threadId) override
~ImageRandomCoordinateSampler() override=default
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType
void BeforeThreadedGenerateData() override
typename InputImageType::SpacingType InputImageSpacingType
itkGetModifiableObjectMacro(Interpolator, InterpolatorType)
ITK_DISALLOW_COPY_AND_MOVE(ImageRandomCoordinateSampler)
virtual void GenerateRandomCoordinate(const InputImageContinuousIndexType &smallestContIndex, const InputImageContinuousIndexType &largestContIndex, InputImageContinuousIndexType &randomContIndex)
typename RandomGeneratorType::Pointer RandomGeneratorPointer
InterpolateImageFunction< InputImageType, CoordRepType > InterpolatorType
itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension)
This class is a base class for any image sampler that randomly picks samples.
SpatialObject< Self::InputImageDimension > MaskType
typename ImageSampleContainerType::Pointer ImageSampleContainerPointer
A class that defines an image sample, which is the coordinates of a point and its value.
typename InputImageType::PointType InputImagePointType
typename InputImageType::SizeType InputImageSizeType
typename InputImagePointType::ValueType InputImagePointValueType
typename ImageSampleType::RealType ImageSampleValueType
typename InputImageType::IndexType InputImageIndexType
TOutputVectorContainer OutputVectorContainerType
typename OutputVectorContainerType::Pointer OutputVectorContainerPointer
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.


Generated on Wed 12 Apr 2023 for elastix by doxygen 1.9.6 elastix logo