ITK  6.0.0
Insight Toolkit
itkRegistrationParameterScalesEstimator.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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 itkRegistrationParameterScalesEstimator_h
19#define itkRegistrationParameterScalesEstimator_h
20
21#include "itkTransform.h"
26
30#include "ITKOptimizersv4Export.h"
31
32namespace itk
33{
39{
40public:
45 enum class SamplingStrategy : uint8_t
46 {
47 FullDomainSampling = 0,
48 CornerSampling,
49 RandomSampling,
50 CentralRegionSampling,
51 VirtualDomainPointSetSampling
52 };
53};
55// Define how to print enumeration
56extern ITKOptimizersv4_EXPORT std::ostream &
58
79template <typename TMetric>
80class ITK_TEMPLATE_EXPORT RegistrationParameterScalesEstimator
81 : public OptimizerParameterScalesEstimatorTemplate<typename TMetric::ParametersValueType>
82{
83public:
84 ITK_DISALLOW_COPY_AND_MOVE(RegistrationParameterScalesEstimator);
85
91
93 itkOverrideGetNameOfClassMacro(RegistrationParameterScalesEstimator);
94
96 using typename Superclass::ScalesType;
97
99 using typename Superclass::ParametersType;
100
102 using typename Superclass::FloatType;
103
104 using MetricType = TMetric;
107
109 using FixedTransformType = typename MetricType::FixedTransformType;
111
112 using MovingTransformType = typename MetricType::MovingTransformType;
114
116 static constexpr SizeValueType FixedDimension = TMetric::FixedDimension;
117 static constexpr SizeValueType MovingDimension = TMetric::MovingDimension;
118 static constexpr SizeValueType VirtualDimension = TMetric::VirtualDimension;
119
120 using VirtualImageType = typename TMetric::VirtualImageType;
121 using VirtualImageConstPointer = typename TMetric::VirtualImageConstPointer;
122 using VirtualImagePointer = typename TMetric::VirtualImagePointer;
123 using VirtualSpacingType = typename TMetric::VirtualSpacingType;
124 using VirtualRegionType = typename TMetric::VirtualRegionType;
125 using VirtualSizeType = typename TMetric::VirtualSizeType;
126 using VirtualPointType = typename TMetric::VirtualPointType;
127 using VirtualIndexType = typename TMetric::VirtualIndexType;
128
129 using VirtualPointSetType = typename TMetric::VirtualPointSetType;
130 using VirtualPointSetPointer = typename TMetric::VirtualPointSetPointer;
131
134#if !defined(ITK_LEGACY_REMOVE)
135 // We need to expose the enum values at the class level
136 // for backwards compatibility
137 static constexpr SamplingStrategyType FullDomainSampling = SamplingStrategyType::FullDomainSampling;
138 static constexpr SamplingStrategyType CornerSampling = SamplingStrategyType::CornerSampling;
139 static constexpr SamplingStrategyType RandomSampling = SamplingStrategyType::RandomSampling;
140 static constexpr SamplingStrategyType CentralRegionSampling = SamplingStrategyType::CentralRegionSampling;
141 static constexpr SamplingStrategyType VirtualDomainPointSetSampling =
142 SamplingStrategyType::VirtualDomainPointSetSampling;
143#endif
144
145 using SamplePointContainerType = std::vector<VirtualPointType>;
146
148 using JacobianType = typename TMetric::JacobianType;
149
154 itkSetObjectMacro(Metric, MetricType);
155 itkGetConstObjectMacro(Metric, MetricType);
162 itkSetMacro(TransformForward, bool);
163 itkGetConstMacro(TransformForward, bool);
164 itkBooleanMacro(TransformForward);
168#ifndef ITK_FUTURE_LEGACY_REMOVE
169 virtual void
170 SetVirtualDomainPointSet(VirtualPointSetType * const arg)
171 {
172 const auto * const constArg = arg;
173 // Call the overload defined by itkSetConstObjectMacro, or an override.
174 this->SetVirtualDomainPointSet(constArg);
175 }
176#endif
177 itkSetConstObjectMacro(VirtualDomainPointSet, VirtualPointSetType);
178 itkGetConstObjectMacro(VirtualDomainPointSet, VirtualPointSetType);
182 itkSetMacro(CentralRegionRadius, IndexValueType);
183 itkGetConstMacro(CentralRegionRadius, IndexValueType);
187 void
188 EstimateScales(ScalesType & scales) override = 0;
189
192 EstimateStepScale(const ParametersType & step) override = 0;
193
195 void
196 EstimateLocalStepScales(const ParametersType & step, ScalesType & localStepScales) override = 0;
197
201
203 virtual void
205
207 virtual void
209
210protected:
213
214 void
215 PrintSelf(std::ostream & os, Indent indent) const override;
216
218 bool
220
222 itkSetMacro(NumberOfRandomSamples, SizeValueType);
223
227
232 bool
234
243 template <typename TTransform>
244 bool
246
252 template <typename TTargetPointType>
253 void
254 TransformPoint(const VirtualPointType & point, TTargetPointType & mappedPoint);
255
257 template <typename TContinuousIndexType>
258 void
259 TransformPointToContinuousIndex(const VirtualPointType & point, TContinuousIndexType & mappedIndex);
260
262 void
264
266 bool
268
270 bool
272
274 bool
276
280
282 void
284
286 virtual void
288
290 void
292
297 void
299
301 void
303
308 void
310
312 void
314
316 void
318
325
329
333
337
341
343 MetricPointer m_Metric{};
344
346 SamplePointContainerType m_SamplePoints{};
347
349 mutable TimeStamp m_SamplingTime{};
350
352 SizeValueType m_NumberOfRandomSamples{};
353
355 IndexValueType m_CentralRegionRadius{};
356
357 typename VirtualPointSetType::ConstPointer m_VirtualDomainPointSet{};
358
359 // the threshold to decide if the number of random samples uses logarithm
360 static constexpr SizeValueType SizeOfSmallDomain = 1000;
361
362private:
367 bool m_TransformForward{};
368
369 // sampling strategy
370 SamplingStrategyType m_SamplingStrategy{};
371
372}; // class RegistrationParameterScalesEstimator
373} // namespace itk
374
375
376#ifndef ITK_MANUAL_INSTANTIATION
377# include "itkRegistrationParameterScalesEstimator.hxx"
378#endif
379
380#endif /* itkRegistrationParameterScalesEstimator_h */
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
OptimizerParameterScalesEstimatorTemplate is the base class offering a empty method of estimating the...
Class to hold and manage different parameter types used during optimization.
This class contains all the enum classes used by RegistrationParameterScalesEstimator class.
Implements a registration helper class for estimating scales of transform parameters and step sizes.
void UpdateTransformParameters(const ParametersType &deltaParameters)
void PrintSelf(std::ostream &os, Indent indent) const override
VirtualRegionType GetVirtualDomainCentralRegion()
const TransformBaseTemplate< typename TMetric::MeasureType > * GetTransform()
void TransformPointToContinuousIndex(const VirtualPointType &point, TContinuousIndexType &mappedIndex)
typename MetricType::MovingTransformType MovingTransformType
void ComputeSquaredJacobianNorms(const VirtualPointType &point, ParametersType &squareNorms)
typename MovingTransformType::ConstPointer MovingTransformConstPointer
void SampleVirtualDomainWithRegion(VirtualRegionType region)
FloatType EstimateMaximumStepSize() override
typename TMetric::VirtualPointSetPointer VirtualPointSetPointer
typename FixedTransformType::ConstPointer FixedTransformConstPointer
void EstimateLocalStepScales(const ParametersType &step, ScalesType &localStepScales) override=0
typename TMetric::VirtualImageConstPointer VirtualImageConstPointer
~RegistrationParameterScalesEstimator() override=default
FloatType EstimateStepScale(const ParametersType &step) override=0
void TransformPoint(const VirtualPointType &point, TTargetPointType &mappedPoint)
void EstimateScales(ScalesType &scales) override=0
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:61
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
*par Constraints *The filter image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
long IndexValueType
Definition: itkIntTypes.h:93
unsigned long SizeValueType
Definition: itkIntTypes.h:86
RegistrationParameterScalesEstimatorEnums::SamplingStrategy SamplingStrategyEnum