ITK  4.13.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:
63 
66 
68  typedef typename Superclass::ScalesType ScalesType;
69 
71  typedef typename Superclass::ParametersType ParametersType;
72 
74  typedef typename Superclass::FloatType FloatType;
75 
76  typedef TMetric MetricType;
77  typedef typename MetricType::Pointer MetricPointer;
78  typedef typename MetricType::ConstPointer MetricConstPointer;
79 
81  typedef typename MetricType::FixedTransformType FixedTransformType;
82  typedef typename FixedTransformType::ConstPointer FixedTransformConstPointer;
83 
84  typedef typename MetricType::MovingTransformType MovingTransformType;
85  typedef typename MovingTransformType::ConstPointer MovingTransformConstPointer;
86 
88  itkStaticConstMacro(FixedDimension, SizeValueType, TMetric::FixedDimension );
89  itkStaticConstMacro(MovingDimension, SizeValueType, TMetric::MovingDimension );
90  itkStaticConstMacro(VirtualDimension, SizeValueType, TMetric::VirtualDimension );
92 
93  typedef typename TMetric::VirtualImageType VirtualImageType;
94  typedef typename TMetric::VirtualImageConstPointer VirtualImageConstPointer;
95  typedef typename TMetric::VirtualImagePointer VirtualImagePointer;
96  typedef typename TMetric::VirtualSpacingType VirtualSpacingType;
97  typedef typename TMetric::VirtualRegionType VirtualRegionType;
98  typedef typename TMetric::VirtualSizeType VirtualSizeType;
99  typedef typename TMetric::VirtualPointType VirtualPointType;
100  typedef typename TMetric::VirtualIndexType VirtualIndexType;
101 
102  typedef typename TMetric::VirtualPointSetType VirtualPointSetType;
103  typedef typename TMetric::VirtualPointSetPointer VirtualPointSetPointer;
104 
106  typedef enum { FullDomainSampling = 0,
110  VirtualDomainPointSetSampling } SamplingStrategyType;
111 
112  typedef std::vector<VirtualPointType> SamplePointContainerType;
113 
115  typedef typename TMetric::JacobianType JacobianType;
116 
121  itkSetObjectMacro(Metric, MetricType);
122 
127  itkSetMacro(TransformForward, bool);
128  itkGetConstMacro(TransformForward, bool);
130 
132  itkSetObjectMacro(VirtualDomainPointSet, VirtualPointSetType);
133  itkSetConstObjectMacro(VirtualDomainPointSet, VirtualPointSetType);
134  itkGetConstObjectMacro(VirtualDomainPointSet, VirtualPointSetType);
136 
138  itkSetMacro(CentralRegionRadius, IndexValueType);
139 
141  virtual void EstimateScales(ScalesType &scales) ITK_OVERRIDE = 0;
142 
144  virtual FloatType EstimateStepScale(const ParametersType &step) ITK_OVERRIDE = 0;
145 
147  virtual void EstimateLocalStepScales(const ParametersType &step, ScalesType &localStepScales) ITK_OVERRIDE = 0;
148 
150  virtual FloatType EstimateMaximumStepSize() ITK_OVERRIDE;
151 
153  virtual void SetScalesSamplingStrategy();
154 
156  virtual void SetStepScaleSamplingStrategy();
157 
158 protected:
160  ~RegistrationParameterScalesEstimator() ITK_OVERRIDE {};
161 
162  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
163 
165  bool CheckAndSetInputs();
166 
168  itkSetMacro(NumberOfRandomSamples, SizeValueType);
169 
172  itkSetMacro(SamplingStrategy, SamplingStrategyType);
173 
178  bool CheckGeneralAffineTransform();
179 
185  template< typename TTransform > bool CheckGeneralAffineTransformTemplated();
186 
188  template< typename TTargetPointType > void TransformPoint( const VirtualPointType &point, TTargetPointType &mappedPoint);
189 
191  template< typename TContinuousIndexType > void TransformPointToContinuousIndex( const VirtualPointType &point,TContinuousIndexType &mappedIndex);
192 
194  void ComputeSquaredJacobianNorms( const VirtualPointType & p, ParametersType & squareNorms);
195 
197  bool TransformHasLocalSupportForScalesEstimation();
198 
200  bool IsDisplacementFieldTransform();
201 
203  bool IsBSplineTransform();
204 
206  SizeValueType GetNumberOfLocalParameters();
207 
209  void UpdateTransformParameters(const ParametersType &deltaParameters);
210 
212  virtual void SampleVirtualDomain();
213 
215  void SampleVirtualDomainFully();
216 
218  void SampleVirtualDomainWithCorners();
219 
221  void SampleVirtualDomainRandomly();
222 
224  void SampleVirtualDomainWithCentralRegion();
225 
227  void SampleVirtualDomainWithRegion(VirtualRegionType region);
228 
230  void SampleVirtualDomainWithPointSet();
231 
233  VirtualIndexType GetVirtualDomainCentralIndex();
234 
236  VirtualRegionType GetVirtualDomainCentralRegion();
237 
240 
242  SizeValueType GetDimension();
243 
246  itkGetMacro( SamplingStrategy, SamplingStrategyType )
247 
248 
249  MetricPointer m_Metric;
250 
252  SamplePointContainerType m_SamplePoints;
253 
255  mutable TimeStamp m_SamplingTime;
256 
258  SizeValueType m_NumberOfRandomSamples;
259 
261  IndexValueType m_CentralRegionRadius;
262 
263  typename VirtualPointSetType::ConstPointer m_VirtualDomainPointSet;
264 
265  // the threadhold to decide if the number of random samples uses logarithm
266  static ITK_CONSTEXPR_VAR SizeValueType SizeOfSmallDomain = 1000;
267 
268 private:
269  ITK_DISALLOW_COPY_AND_ASSIGN(RegistrationParameterScalesEstimator);
270 
275  bool m_TransformForward;
276 
277  // sampling stategy
278  SamplingStrategyType m_SamplingStrategy;
279 
280 }; //class RegistrationParameterScalesEstimator
281 
282 
283 } // namespace itk
284 
285 
286 #ifndef ITK_MANUAL_INSTANTIATION
287 #include "itkRegistrationParameterScalesEstimator.hxx"
288 #endif
289 
290 #endif /* itkRegistrationParameterScalesEstimator_h */
Light weight base class for most itk classes.
signed long IndexValueType
Definition: itkIntTypes.h:150
OptimizerParameterScalesEstimatorTemplate< typename TMetric::ParametersValueType > Superclass
unsigned long SizeValueType
Definition: itkIntTypes.h:143
OptimizerParameterScalesEstimatorTemplate is the base class offering a empty method of estimating the...
Implements a registration helper class for estimating scales of transform parameters and step sizes...
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:59
Control indentation during Print() invocation.
Definition: itkIndent.h:49