ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkRegistrationParameterScalesEstimator.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 itkRegistrationParameterScalesEstimator_h
19 #define itkRegistrationParameterScalesEstimator_h
20 
21 #include "itkTransform.h"
24 #include "itkIdentityTransform.h"
26 
30 
31 namespace itk
32 {
33 
53 template < typename TMetric >
54 class ITK_TEMPLATE_EXPORT RegistrationParameterScalesEstimator
55  : public OptimizerParameterScalesEstimatorTemplate<typename TMetric::ParametersValueType>
56 {
57 public:
58  ITK_DISALLOW_COPY_AND_ASSIGN(RegistrationParameterScalesEstimator);
59 
65 
68 
70  using ScalesType = typename Superclass::ScalesType;
71 
73  using ParametersType = typename Superclass::ParametersType;
74 
76  using FloatType = typename Superclass::FloatType;
77 
78  using MetricType = TMetric;
79  using MetricPointer = typename MetricType::Pointer;
80  using MetricConstPointer = typename MetricType::ConstPointer;
81 
83  using FixedTransformType = typename MetricType::FixedTransformType;
84  using FixedTransformConstPointer = typename FixedTransformType::ConstPointer;
85 
86  using MovingTransformType = typename MetricType::MovingTransformType;
87  using MovingTransformConstPointer = typename MovingTransformType::ConstPointer;
88 
90  static constexpr SizeValueType FixedDimension = TMetric::FixedDimension;
91  static constexpr SizeValueType MovingDimension = TMetric::MovingDimension;
92  static constexpr SizeValueType VirtualDimension = TMetric::VirtualDimension;
93 
94  using VirtualImageType = typename TMetric::VirtualImageType;
95  using VirtualImageConstPointer = typename TMetric::VirtualImageConstPointer;
96  using VirtualImagePointer = typename TMetric::VirtualImagePointer;
97  using VirtualSpacingType = typename TMetric::VirtualSpacingType;
98  using VirtualRegionType = typename TMetric::VirtualRegionType;
99  using VirtualSizeType = typename TMetric::VirtualSizeType;
100  using VirtualPointType = typename TMetric::VirtualPointType;
101  using VirtualIndexType = typename TMetric::VirtualIndexType;
102 
103  using VirtualPointSetType = typename TMetric::VirtualPointSetType;
104  using VirtualPointSetPointer = typename TMetric::VirtualPointSetPointer;
105 
107  typedef enum { FullDomainSampling = 0,
111  VirtualDomainPointSetSampling } SamplingStrategyType;
112 
113  using SamplePointContainerType = std::vector<VirtualPointType>;
114 
116  using JacobianType = typename TMetric::JacobianType;
117 
122  itkSetObjectMacro(Metric, MetricType);
123 
128  itkSetMacro(TransformForward, bool);
129  itkGetConstMacro(TransformForward, bool);
131 
133  itkSetObjectMacro(VirtualDomainPointSet, VirtualPointSetType);
134  itkSetConstObjectMacro(VirtualDomainPointSet, VirtualPointSetType);
135  itkGetConstObjectMacro(VirtualDomainPointSet, VirtualPointSetType);
137 
139  itkSetMacro(CentralRegionRadius, IndexValueType);
140 
142  void EstimateScales(ScalesType &scales) override = 0;
143 
145  FloatType EstimateStepScale(const ParametersType &step) override = 0;
146 
148  void EstimateLocalStepScales(const ParametersType &step, ScalesType &localStepScales) override = 0;
149 
151  FloatType EstimateMaximumStepSize() override;
152 
154  virtual void SetScalesSamplingStrategy();
155 
157  virtual void SetStepScaleSamplingStrategy();
158 
159 protected:
161  ~RegistrationParameterScalesEstimator() override = default;
162 
163  void PrintSelf(std::ostream & os, Indent indent) const override;
164 
166  bool CheckAndSetInputs();
167 
169  itkSetMacro(NumberOfRandomSamples, SizeValueType);
170 
173  itkSetMacro(SamplingStrategy, SamplingStrategyType);
174 
179  bool CheckGeneralAffineTransform();
180 
186  template< typename TTransform > bool CheckGeneralAffineTransformTemplated();
187 
189  template< typename TTargetPointType > void TransformPoint( const VirtualPointType &point, TTargetPointType &mappedPoint);
190 
192  template< typename TContinuousIndexType > void TransformPointToContinuousIndex( const VirtualPointType &point,TContinuousIndexType &mappedIndex);
193 
195  void ComputeSquaredJacobianNorms( const VirtualPointType & p, ParametersType & squareNorms);
196 
198  bool TransformHasLocalSupportForScalesEstimation();
199 
201  bool IsDisplacementFieldTransform();
202 
204  bool IsBSplineTransform();
205 
207  SizeValueType GetNumberOfLocalParameters();
208 
210  void UpdateTransformParameters(const ParametersType &deltaParameters);
211 
213  virtual void SampleVirtualDomain();
214 
216  void SampleVirtualDomainFully();
217 
219  void SampleVirtualDomainWithCorners();
220 
222  void SampleVirtualDomainRandomly();
223 
225  void SampleVirtualDomainWithCentralRegion();
226 
228  void SampleVirtualDomainWithRegion(VirtualRegionType region);
229 
231  void SampleVirtualDomainWithPointSet();
232 
234  VirtualIndexType GetVirtualDomainCentralIndex();
235 
237  VirtualRegionType GetVirtualDomainCentralRegion();
238 
241 
243  SizeValueType GetDimension();
244 
247  itkGetMacro( SamplingStrategy, SamplingStrategyType )
248 
249 
250  MetricPointer m_Metric;
251 
253  SamplePointContainerType m_SamplePoints;
254 
256  mutable TimeStamp m_SamplingTime;
257 
259  SizeValueType m_NumberOfRandomSamples;
260 
262  IndexValueType m_CentralRegionRadius;
263 
264  typename VirtualPointSetType::ConstPointer m_VirtualDomainPointSet;
265 
266  // the threadhold to decide if the number of random samples uses logarithm
267  static constexpr SizeValueType SizeOfSmallDomain = 1000;
268 
269 private:
274  bool m_TransformForward;
275 
276  // sampling stategy
277  SamplingStrategyType m_SamplingStrategy;
278 
279 }; //class RegistrationParameterScalesEstimator
280 
281 
282 } // namespace itk
283 
284 
285 #ifndef ITK_MANUAL_INSTANTIATION
286 #include "itkRegistrationParameterScalesEstimator.hxx"
287 #endif
288 
289 #endif /* itkRegistrationParameterScalesEstimator_h */
Light weight base class for most itk classes.
typename MetricType::MovingTransformType MovingTransformType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
typename MetricType::FixedTransformType FixedTransformType
typename FixedTransformType::ConstPointer FixedTransformConstPointer
OptimizerParameterScalesEstimatorTemplate is the base class offering a empty method of estimating the...
typename TMetric::VirtualImageConstPointer VirtualImageConstPointer
typename MovingTransformType::ConstPointer MovingTransformConstPointer
signed long IndexValueType
Definition: itkIntTypes.h:90
Implements a registration helper class for estimating scales of transform parameters and step sizes...
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:60
typename TMetric::VirtualPointSetPointer VirtualPointSetPointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49