ITK  4.3.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 < class TMetric >
55 {
56 public:
62 
65 
67  typedef typename Superclass::ScalesType ScalesType;
68 
70  typedef typename Superclass::ParametersType ParametersType;
71 
73  typedef typename Superclass::FloatType FloatType;
74 
75  typedef TMetric MetricType;
76  typedef typename MetricType::Pointer MetricPointer;
77  typedef typename MetricType::ConstPointer MetricConstPointer;
78 
80  typedef typename MetricType::FixedTransformType FixedTransformType;
81  typedef typename FixedTransformType::ConstPointer FixedTransformConstPointer;
82 
83  typedef typename MetricType::MovingTransformType MovingTransformType;
84  typedef typename MovingTransformType::ConstPointer MovingTransformConstPointer;
85 
87  itkStaticConstMacro(FixedDimension, SizeValueType, TMetric::FixedDimension );
88  itkStaticConstMacro(MovingDimension, SizeValueType, TMetric::MovingDimension );
89  itkStaticConstMacro(VirtualDimension, SizeValueType, TMetric::VirtualDimension );
91 
92  typedef typename TMetric::VirtualImageType VirtualImageType;
93  typedef typename TMetric::VirtualImageConstPointer VirtualImageConstPointer;
94  typedef typename TMetric::VirtualImagePointer VirtualImagePointer;
95  typedef typename TMetric::VirtualSpacingType VirtualSpacingType;
96  typedef typename TMetric::VirtualRegionType VirtualRegionType;
97  typedef typename TMetric::VirtualSizeType VirtualSizeType;
98  typedef typename TMetric::VirtualPointType VirtualPointType;
99  typedef typename TMetric::VirtualIndexType VirtualIndexType;
100 
101  typedef typename TMetric::VirtualPointSetType VirtualPointSetType;
102  typedef typename TMetric::VirtualPointSetPointer VirtualPointSetPointer;
103 
105  typedef enum { FullDomainSampling = 0,
109  VirtualDomainPointSetSampling } SamplingStrategyType;
110 
111  typedef std::vector<VirtualPointType> SamplePointContainerType;
112 
114  typedef typename TMetric::JacobianType JacobianType;
115 
120  itkSetObjectMacro(Metric, MetricType);
121 
126  itkSetMacro(TransformForward, bool);
127  itkGetConstMacro(TransformForward, bool);
129 
131  itkSetObjectMacro(VirtualDomainPointSet, VirtualPointSetType);
132  itkSetConstObjectMacro(VirtualDomainPointSet, VirtualPointSetType);
133  itkGetConstObjectMacro(VirtualDomainPointSet, VirtualPointSetType);
135 
137  itkSetMacro(CentralRegionRadius, IndexValueType);
138 
140  virtual void EstimateScales(ScalesType &scales) = 0;
141 
143  virtual FloatType EstimateStepScale(const ParametersType &step) = 0;
144 
146  virtual void EstimateLocalStepScales(const ParametersType &step, ScalesType &localStepScales) = 0;
147 
149  virtual FloatType EstimateMaximumStepSize();
150 
152  virtual void SetScalesSamplingStrategy();
153 
155  virtual void SetStepScaleSamplingStrategy();
156 
157 protected:
160 
161  virtual void PrintSelf(std::ostream &os, Indent indent) const;
162 
164  bool CheckAndSetInputs();
165 
167  itkSetMacro(NumberOfRandomSamples, SizeValueType);
168 
171  itkSetMacro(SamplingStrategy, SamplingStrategyType);
172 
177  bool CheckGeneralAffineTransform();
178 
184  template< class TTransform > bool CheckGeneralAffineTransformTemplated();
185 
187  template< class TTargetPointType > void TransformPoint( const VirtualPointType &point, TTargetPointType &mappedPoint);
188 
190  template< class TContinuousIndexType > void TransformPointToContinuousIndex( const VirtualPointType &point,TContinuousIndexType &mappedIndex);
191 
193  void ComputeSquaredJacobianNorms( const VirtualPointType & p, ParametersType & squareNorms);
194 
196  bool TransformHasLocalSupportForScalesEstimation();
197 
199  bool IsDisplacementFieldTransform();
200 
202  bool IsBSplineTransform();
203 
205  SizeValueType GetNumberOfLocalParameters();
206 
208  void UpdateTransformParameters(const ParametersType &deltaParameters);
209 
211  virtual void SampleVirtualDomain();
212 
214  void SampleVirtualDomainFully();
215 
217  void SampleVirtualDomainWithCorners();
218 
220  void SampleVirtualDomainRandomly();
221 
223  void SampleVirtualDomainWithCentralRegion();
224 
226  void SampleVirtualDomainWithRegion(VirtualRegionType region);
227 
229  void SampleVirtualDomainWithPointSet();
230 
232  VirtualIndexType GetVirtualDomainCentralIndex();
233 
235  VirtualRegionType GetVirtualDomainCentralRegion();
236 
238  const TransformBase *GetTransform();
239 
241  SizeValueType GetDimension();
242 
245  itkGetMacro( SamplingStrategy, SamplingStrategyType )
246 
247 
248  MetricPointer m_Metric;
249 
251  SamplePointContainerType m_SamplePoints;
252 
254  mutable TimeStamp m_SamplingTime;
255 
257  SizeValueType m_NumberOfRandomSamples;
258 
260  IndexValueType m_CentralRegionRadius;
261 
262  typename VirtualPointSetType::ConstPointer m_VirtualDomainPointSet;
263 
264  // the threadhold to decide if the number of random samples uses logarithm
265  static const SizeValueType SizeOfSmallDomain = 1000;
266 
267 private:
268  RegistrationParameterScalesEstimator(const Self&); //purposely not implemented
269  void operator=(const Self&); //purposely not implemented
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 */
291