ITK  4.13.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<typename TParametersValueType,
61  unsigned int NDimensions>
62 class ITK_TEMPLATE_EXPORT KernelTransform :
63  public Transform<TParametersValueType, NDimensions, NDimensions>
64 {
65 public:
71 
73  itkTypeMacro(KernelTransform, Transform);
74 
76  itkNewMacro(Self);
77 
79  itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
80 
82  typedef typename Superclass::ScalarType ScalarType;
83 
85  typedef typename Superclass::FixedParametersType FixedParametersType;
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 
111  typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
112 
117 
123 
127 
129  itkGetModifiableObjectMacro(SourceLandmarks, PointSetType); //NOTE: This is used to circumvent the SetTargetLandmarks
130  virtual void SetSourceLandmarks(PointSetType *);
132 
134  itkGetModifiableObjectMacro(TargetLandmarks, PointSetType); //NOTE: This is used to circumvent the SetTargetLandmarks
135  virtual void SetTargetLandmarks(PointSetType *);
137 
140  itkGetModifiableObjectMacro(Displacements, VectorSetType);
141 
143  void ComputeWMatrix();
144 
146  virtual OutputPointType TransformPoint(const InputPointType & thisPoint) const ITK_OVERRIDE;
147 
149  using Superclass::TransformVector;
150  virtual OutputVectorType TransformVector(const InputVectorType &) const ITK_OVERRIDE
151  {
152  itkExceptionMacro( << "TransformVector(const InputVectorType &) is not implemented for KernelTransform");
153  }
155 
156  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const ITK_OVERRIDE
157  {
158  itkExceptionMacro( << "TransformVector(const InputVnlVectorType &) is not implemented for KernelTransform");
159  }
160 
162  using Superclass::TransformCovariantVector;
164  {
165  itkExceptionMacro( << "TransformCovariantVector(const InputCovariantVectorType &) is not implemented for KernelTransform");
166  }
168 
170  typedef vnl_matrix_fixed<TParametersValueType, NDimensions, NDimensions> IMatrixType;
171 
173  virtual void ComputeJacobianWithRespectToParameters( const InputPointType & p, JacobianType & jacobian) const ITK_OVERRIDE;
174 
176  JacobianType &) const ITK_OVERRIDE
177  {
178  itkExceptionMacro( "ComputeJacobianWithRespectToPosition not yet implemented "
179  "for " << this->GetNameOfClass() );
180  }
181 
186  virtual void SetParameters(const ParametersType &) ITK_OVERRIDE;
187 
193  virtual void SetFixedParameters(const FixedParametersType &) ITK_OVERRIDE;
194 
196  virtual void UpdateParameters() const;
197 
199  virtual const ParametersType & GetParameters() const ITK_OVERRIDE;
200 
202  virtual const FixedParametersType & GetFixedParameters() const ITK_OVERRIDE;
203 
207  virtual TransformCategoryType GetTransformCategory() const ITK_OVERRIDE
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 ITK_OVERRIDE;
230 
231 public:
233  typedef vnl_matrix_fixed<TParametersValueType, NDimensions, NDimensions> GMatrixType;
234 
236  typedef vnl_matrix<TParametersValueType> LMatrixType;
237 
239  typedef vnl_matrix<TParametersValueType> KMatrixType;
240 
242  typedef vnl_matrix<TParametersValueType> PMatrixType;
243 
245  typedef vnl_matrix<TParametersValueType> YMatrixType;
246 
248  typedef vnl_matrix<TParametersValueType> WMatrixType;
249 
251  typedef vnl_matrix<TParametersValueType> DMatrixType;
252 
254  typedef vnl_matrix_fixed<TParametersValueType, NDimensions, NDimensions> AMatrixType;
255 
257  typedef vnl_vector_fixed<TParametersValueType, NDimensions> BMatrixType;
258 
260  typedef vnl_matrix_fixed<TParametersValueType, 1, NDimensions> RowMatrixType;
261 
263  typedef vnl_matrix_fixed<TParametersValueType, 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();
309 
311  double m_Stiffness;
312 
316 
319 
322 
325 
328 
331 
338 
341 
344 
349 
352 
355 
358 
361 
362 private:
363 
364  ITK_DISALLOW_COPY_AND_ASSIGN(KernelTransform);
365 
366 };
367 } // end namespace itk
368 
369 #ifndef ITK_MANUAL_INSTANTIATION
370 #include "itkKernelTransform.hxx"
371 #endif
372 
373 #endif // itkKernelTransform_h
vnl_matrix< TParametersValueType > DMatrixType
PointSetPointer m_TargetLandmarks
PointSetType::PointIdentifier PointIdentifier
PointSetType::Pointer PointSetPointer
Light weight base class for most itk classes.
PointSetType::PointsContainerIterator PointsIterator
Superclass::InputVectorType InputVectorType
Superclass::InputPointType InputPointType
MeshTraits::PointIdentifier PointIdentifier
Definition: itkPointSet.h:105
vnl_matrix< TParametersValueType > LMatrixType
virtual void ComputeJacobianWithRespectToPosition(const InputPointType &, JacobianType &) const override
Superclass::NumberOfParametersType NumberOfParametersType
PointSetType::PointsContainer PointsContainer
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const override
virtual OutputVectorType TransformVector(const InputVectorType &) const override
vnl_matrix< TParametersValueType > YMatrixType
Superclass::ScalarType ScalarType
vnl_matrix_fixed< TParametersValueType, NDimensions, 1 > ColumnMatrixType
Superclass::ParametersType ParametersType
DefaultStaticMeshTraits< TParametersValueType, NDimensions, NDimensions, TParametersValueType, TParametersValueType > PointSetTraitsType
Superclass::FixedParametersType FixedParametersType
vnl_matrix_fixed< TParametersValueType, 1, NDimensions > RowMatrixType
PointsContainer::ConstIterator PointsContainerConstIterator
Definition: itkPointSet.h:121
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
SmartPointer< const Self > ConstPointer
PointSetPointer m_SourceLandmarks
Superclass::OutputCovariantVectorType OutputCovariantVectorType
vnl_matrix< TParametersValueType > WMatrixType
Superclass::OutputVectorType OutputVectorType
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:84
vnl_matrix_fixed< TParametersValueType, NDimensions, NDimensions > GMatrixType
itk::VectorContainer< SizeValueType, InputVectorType > VectorSetType
MeshTraits::PointsContainer PointsContainer
Definition: itkPointSet.h:107
Superclass::OutputVnlVectorType OutputVnlVectorType
SmartPointer< Self > Pointer
Superclass::TransformCategoryType TransformCategoryType
vnl_matrix< TParametersValueType > KMatrixType
vnl_matrix_fixed< TParametersValueType, NDimensions, NDimensions > IMatrixType
Superclass::InputCovariantVectorType InputCovariantVectorType
vnl_matrix_fixed< TParametersValueType, NDimensions, NDimensions > AMatrixType
PointSet< InputPointType, NDimensions, PointSetTraitsType > PointSetType
Superclass::JacobianType JacobianType
VectorSetType::Pointer VectorSetPointer
Define a front-end to the STL &quot;vector&quot; container that conforms to the IndexedContainerInterface.
PointSetType::PointsContainerConstIterator PointsConstIterator
Control indentation during Print() invocation.
Definition: itkIndent.h:49
vnl_matrix< TParametersValueType > PMatrixType
VectorSetPointer m_Displacements
Transform< TParametersValueType, NDimensions, NDimensions > Superclass
Define additional traits for native types such as int or float.
Superclass::InputVnlVectorType InputVnlVectorType
virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const override
PointsContainer::Iterator PointsContainerIterator
Definition: itkPointSet.h:122
Superclass::OutputPointType OutputPointType
vnl_vector_fixed< TParametersValueType, NDimensions > BMatrixType