ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkKernelTransform.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 __itkKernelTransform_h
19 #define __itkKernelTransform_h
20 
21 #include "itkTransform.h"
22 #include "itkMatrix.h"
23 #include "itkPointSet.h"
24 #include <deque>
25 #include <cmath>
26 #include "vnl/vnl_matrix_fixed.h"
27 #include "vnl/vnl_matrix.h"
28 #include "vnl/vnl_vector.h"
29 #include "vnl/vnl_vector_fixed.h"
30 #include "vnl/algo/vnl_svd.h"
31 #include "vnl/vnl_sample.h"
32 
33 namespace itk
34 {
60 template <class TScalarType, // probably only float and double make sense here
61  unsigned int NDimensions>
62 // Number of dimensions
63 class ITK_EXPORT KernelTransform :
64  public Transform<TScalarType, NDimensions, NDimensions>
65 {
66 public:
72 
74  itkTypeMacro(KernelTransform, Transform);
75 
77  itkNewMacro(Self);
78 
80  itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
81 
83  typedef typename Superclass::ScalarType ScalarType;
84 
86  typedef typename Superclass::ParametersType ParametersType;
87 
89  typedef typename Superclass::JacobianType JacobianType;
90 
92  typedef typename Superclass::TransformCategoryType TransformCategoryType;
93 
95  typedef typename Superclass::InputPointType InputPointType;
96  typedef typename Superclass::OutputPointType OutputPointType;
97 
99  typedef typename Superclass::InputVectorType InputVectorType;
100  typedef typename Superclass::OutputVectorType OutputVectorType;
101 
103  typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType;
104  typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType;
105 
107  typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
108  typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
109 
114 
120 
124 
126  itkGetModifiableObjectMacro(SourceLandmarks, PointSetType); //NOTE: This is used to circumvent the SetTargetLandmarks
127  virtual void SetSourceLandmarks(PointSetType *);
129 
131  itkGetModifiableObjectMacro(TargetLandmarks, PointSetType); //NOTE: This is used to circumvent the SetTargetLandmarks
132  virtual void SetTargetLandmarks(PointSetType *);
134 
137  itkGetModifiableObjectMacro(Displacements, VectorSetType);
138 
140  void ComputeWMatrix(void);
141 
143  virtual OutputPointType TransformPoint(const InputPointType & thisPoint) const;
144 
146  using Superclass::TransformVector;
147  virtual OutputVectorType TransformVector(const InputVectorType &) const \
148  { \
149  itkExceptionMacro( \
150  << "TransformVector(const InputVectorType &) is not implemented for KernelTransform"); \
151  }
153 
154  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const \
155  { \
156  itkExceptionMacro( \
157  << "TransformVector(const InputVnlVectorType &) is not implemented for KernelTransform"); \
158  }
159 
161  using Superclass::TransformCovariantVector;
162  virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const \
163  { \
164  itkExceptionMacro( \
165  << "TransformCovariantVector(const InputCovariantVectorType &) is not implemented for KernelTransform"); \
166  }
168 
170  typedef vnl_matrix_fixed<TScalarType, NDimensions, NDimensions> IMatrixType;
171 
173  virtual void ComputeJacobianWithRespectToParameters( const InputPointType & p, JacobianType & jacobian) const;
174 
175  virtual void ComputeJacobianWithRespectToPosition(const InputPointType &,
176  JacobianType &) const \
177  { \
178  itkExceptionMacro( "ComputeJacobianWithRespectToPosition not yet implemented " \
179  "for " << this->GetNameOfClass() ); \
180  }
181 
186  virtual void SetParameters(const ParametersType &);
187 
193  virtual void SetFixedParameters(const ParametersType &);
194 
196  virtual void UpdateParameters(void) const;
197 
199  virtual const ParametersType & GetParameters(void) const;
200 
202  virtual const ParametersType & GetFixedParameters(void) const;
203 
207  virtual TransformCategoryType GetTransformCategory() const
208  {
209  return Self::Spline;
210  }
211 
222  itkSetClampMacro( Stiffness, double, 0.0, NumericTraits<double>::max() );
223  itkGetConstMacro(Stiffness, double);
225 
226 protected:
227  KernelTransform();
228  virtual ~KernelTransform();
229  void PrintSelf(std::ostream & os, Indent indent) const;
230 
231 public:
233  typedef vnl_matrix_fixed<TScalarType, NDimensions, NDimensions> GMatrixType;
234 
236  typedef vnl_matrix<TScalarType> LMatrixType;
237 
239  typedef vnl_matrix<TScalarType> KMatrixType;
240 
242  typedef vnl_matrix<TScalarType> PMatrixType;
243 
245  typedef vnl_matrix<TScalarType> YMatrixType;
246 
248  typedef vnl_matrix<TScalarType> WMatrixType;
249 
251  typedef vnl_matrix<TScalarType> DMatrixType;
252 
254  typedef vnl_matrix_fixed<TScalarType, NDimensions, NDimensions> AMatrixType;
255 
257  typedef vnl_vector_fixed<TScalarType, NDimensions> BMatrixType;
258 
260  typedef vnl_matrix_fixed<TScalarType, 1, NDimensions> RowMatrixType;
261 
263  typedef vnl_matrix_fixed<TScalarType, NDimensions, 1> ColumnMatrixType;
264 
265 protected:
272  virtual void ComputeG(const InputVectorType & landmarkVector, GMatrixType & gmatrix) const;
273 
283  virtual const GMatrixType & ComputeReflexiveG(PointsIterator) const;
284 
287  virtual void ComputeDeformationContribution(const InputPointType & inputPoint, OutputPointType & result) const;
288 
290  void ComputeK();
291 
293  void ComputeL();
294 
296  void ComputeP();
297 
299  void ComputeY();
300 
302  void ComputeD();
303 
308  void ReorganizeW(void);
309 
311  double m_Stiffness;
312 
316 
319 
322 
325 
328 
331 
338 
341 
344 
349 
352 
355 
358 
361 
362 private:
363 
364  KernelTransform(const Self &); // purposely not implemented
365  void operator=(const Self &); // purposely not implemented
366 
367 };
368 } // end namespace itk
369 
370 #ifndef ITK_MANUAL_INSTANTIATION
371 #include "itkKernelTransform.hxx"
372 #endif
373 
374 #endif // __itkKernelTransform_h
375