ITK  4.2.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 HasLocalSupport();
197 
199  SizeValueType GetNumberOfLocalParameters();
200 
202  void UpdateTransformParameters(const ParametersType &deltaParameters);
203 
205  virtual void SampleVirtualDomain();
206 
208  void SampleVirtualDomainFully();
209 
211  void SampleVirtualDomainWithCorners();
212 
214  void SampleVirtualDomainRandomly();
215 
217  void SampleVirtualDomainWithCentralRegion();
218 
220  void SampleVirtualDomainWithRegion(VirtualRegionType region);
221 
223  void SampleVirtualDomainWithPointSet();
224 
226  VirtualIndexType GetVirtualDomainCentralIndex();
227 
229  VirtualRegionType GetVirtualDomainCentralRegion();
230 
232  const TransformBase *GetTransform();
233 
236 
239  itkGetMacro( SamplingStrategy, SamplingStrategyType )
240 
241 
242  MetricPointer m_Metric;
243 
245  SamplePointContainerType m_SamplePoints;
246 
248  mutable TimeStamp m_SamplingTime;
249 
251  SizeValueType m_NumberOfRandomSamples;
252 
254  IndexValueType m_CentralRegionRadius;
255 
256  typename VirtualPointSetType::ConstPointer m_VirtualDomainPointSet;
257 
258  // the threadhold to decide if the number of random samples uses logarithm
259  static const SizeValueType SizeOfSmallDomain = 1000;
260 
261 private:
262  RegistrationParameterScalesEstimator(const Self&); //purposely not implemented
263  void operator=(const Self&); //purposely not implemented
264 
269  bool m_TransformForward;
270 
271  // sampling stategy
272  SamplingStrategyType m_SamplingStrategy;
273 
274 }; //class RegistrationParameterScalesEstimator
275 
276 
277 } // namespace itk
278 
279 
280 #ifndef ITK_MANUAL_INSTANTIATION
281 #include "itkRegistrationParameterScalesEstimator.hxx"
282 #endif
283 
284 #endif /* __itkRegistrationParameterScalesEstimator_h */
285