ITK  5.2.0
Insight Toolkit
itkKernelTransform.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 
32 namespace itk
33 {
60 template <typename TParametersValueType, unsigned int NDimensions>
61 class ITK_TEMPLATE_EXPORT KernelTransform : public Transform<TParametersValueType, NDimensions, NDimensions>
62 {
63 public:
64  ITK_DISALLOW_COPY_AND_MOVE(KernelTransform);
65 
71 
73  itkTypeMacro(KernelTransform, Transform);
74 
76  itkNewMacro(Self);
77 
79  static constexpr unsigned int SpaceDimension = NDimensions;
80 
82  using ScalarType = typename Superclass::ScalarType;
83 
85  using FixedParametersType = typename Superclass::FixedParametersType;
86  using ParametersType = typename Superclass::ParametersType;
87 
89  using JacobianType = typename Superclass::JacobianType;
90  using JacobianPositionType = typename Superclass::JacobianPositionType;
91  using InverseJacobianPositionType = typename Superclass::InverseJacobianPositionType;
92 
94  using TransformCategoryEnum = typename Superclass::TransformCategoryEnum;
95 
97  using InputPointType = typename Superclass::InputPointType;
98  using OutputPointType = typename Superclass::OutputPointType;
99 
101  using InputVectorType = typename Superclass::InputVectorType;
102  using OutputVectorType = typename Superclass::OutputVectorType;
103 
105  using InputCovariantVectorType = typename Superclass::InputCovariantVectorType;
106  using OutputCovariantVectorType = typename Superclass::OutputCovariantVectorType;
107 
109  using InputVnlVectorType = typename Superclass::InputVnlVectorType;
110  using OutputVnlVectorType = typename Superclass::OutputVnlVectorType;
111 
113  using NumberOfParametersType = typename Superclass::NumberOfParametersType;
114 
117  using PointSetTraitsType =
120 
126 
130 
132  itkGetModifiableObjectMacro(SourceLandmarks, PointSetType); // NOTE: This is used to circumvent the SetTargetLandmarks
133  virtual void
134  SetSourceLandmarks(PointSetType *);
136 
138  itkGetModifiableObjectMacro(TargetLandmarks, PointSetType); // NOTE: This is used to circumvent the SetTargetLandmarks
139  virtual void
140  SetTargetLandmarks(PointSetType *);
142 
145  itkGetModifiableObjectMacro(Displacements, VectorSetType);
146 
148  void
149  ComputeWMatrix();
150 
153  TransformPoint(const InputPointType & thisPoint) const override;
154 
156  using Superclass::TransformVector;
158  TransformVector(const InputVectorType &) const override
159  {
160  itkExceptionMacro(<< "TransformVector(const InputVectorType &) is not implemented for KernelTransform");
161  }
163 
164  OutputVnlVectorType
165  TransformVector(const InputVnlVectorType &) const override
166  {
167  itkExceptionMacro(<< "TransformVector(const InputVnlVectorType &) is not implemented for KernelTransform");
168  }
169 
171  using Superclass::TransformCovariantVector;
172  OutputCovariantVectorType
174  {
175  itkExceptionMacro(
176  << "TransformCovariantVector(const InputCovariantVectorType &) is not implemented for KernelTransform");
177  }
179 
181  using IMatrixType = vnl_matrix_fixed<TParametersValueType, NDimensions, NDimensions>;
182 
184  void
185  ComputeJacobianWithRespectToParameters(const InputPointType & p, JacobianType & jacobian) const override;
186 
187  void
189  {
190  itkExceptionMacro("ComputeJacobianWithRespectToPosition not yet implemented "
191  "for "
192  << this->GetNameOfClass());
193  }
194  using Superclass::ComputeJacobianWithRespectToPosition;
195 
200  void
201  SetParameters(const ParametersType &) override;
202 
208  void
209  SetFixedParameters(const FixedParametersType &) override;
210 
212  virtual void
213  UpdateParameters() const;
214 
216  const ParametersType &
217  GetParameters() const override;
218 
220  const FixedParametersType &
221  GetFixedParameters() const override;
222 
226  TransformCategoryEnum
227  GetTransformCategory() const override
228  {
229  return Self::TransformCategoryEnum::Spline;
230  }
231 
242  itkSetClampMacro(Stiffness, double, 0.0, NumericTraits<double>::max());
243  itkGetConstMacro(Stiffness, double);
245 
246 protected:
247  KernelTransform();
248  ~KernelTransform() override = default;
249  void
250  PrintSelf(std::ostream & os, Indent indent) const override;
251 
252 public:
254  using GMatrixType = vnl_matrix_fixed<TParametersValueType, NDimensions, NDimensions>;
255 
257  using LMatrixType = vnl_matrix<TParametersValueType>;
258 
260  using KMatrixType = vnl_matrix<TParametersValueType>;
261 
263  using PMatrixType = vnl_matrix<TParametersValueType>;
264 
266  using YMatrixType = vnl_matrix<TParametersValueType>;
267 
269  using WMatrixType = vnl_matrix<TParametersValueType>;
270 
272  using DMatrixType = vnl_matrix<TParametersValueType>;
273 
275  using AMatrixType = vnl_matrix_fixed<TParametersValueType, NDimensions, NDimensions>;
276 
278  using BMatrixType = vnl_vector_fixed<TParametersValueType, NDimensions>;
279 
281  using RowMatrixType = vnl_matrix_fixed<TParametersValueType, 1, NDimensions>;
282 
284  using ColumnMatrixType = vnl_matrix_fixed<TParametersValueType, NDimensions, 1>;
285 
286 protected:
293  virtual void
294  ComputeG(const InputVectorType & landmarkVector, GMatrixType & gmatrix) const;
295 
305  virtual const GMatrixType & ComputeReflexiveG(PointsIterator) const;
306 
309  virtual void
310  ComputeDeformationContribution(const InputPointType & thisPoint, OutputPointType & result) const;
311 
313  void
314  ComputeK();
315 
317  void
318  ComputeL();
319 
321  void
322  ComputeP();
323 
325  void
326  ComputeY();
327 
329  void
330  ComputeD();
331 
336  void
337  ReorganizeW();
338 
340  double m_Stiffness;
341 
345 
348 
351 
354 
357 
360 
367 
370 
373 
378 
381 
384 
387 
390 
391 private:
392 };
393 } // end namespace itk
394 
395 #ifndef ITK_MANUAL_INSTANTIATION
396 # include "itkKernelTransform.hxx"
397 #endif
398 
399 #endif // itkKernelTransform_h
itk::KernelTransform::InverseJacobianPositionType
typename Superclass::InverseJacobianPositionType InverseJacobianPositionType
Definition: itkKernelTransform.h:91
itk::KernelTransform::YMatrixType
vnl_matrix< TParametersValueType > YMatrixType
Definition: itkKernelTransform.h:266
itk::KernelTransform::PointSetPointer
typename PointSetType::Pointer PointSetPointer
Definition: itkKernelTransform.h:121
itk::KernelTransform::KMatrixType
vnl_matrix< TParametersValueType > KMatrixType
Definition: itkKernelTransform.h:260
itk::DefaultStaticMeshTraits
Definition: itkDefaultStaticMeshTraits.h:61
itk::KernelTransform::IMatrixType
vnl_matrix_fixed< TParametersValueType, NDimensions, NDimensions > IMatrixType
Definition: itkKernelTransform.h:181
itk::KernelTransform::ScalarType
typename Superclass::ScalarType ScalarType
Definition: itkKernelTransform.h:82
itk::PointSet::PointsContainerIterator
typename PointsContainer::Iterator PointsContainerIterator
Definition: itkPointSet.h:121
itk::PointSet
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:82
itk::KernelTransform::m_GMatrix
GMatrixType m_GMatrix
Definition: itkKernelTransform.h:377
itkMatrix.h
itk::KernelTransform::m_I
IMatrixType m_I
Definition: itkKernelTransform.h:383
itk::KernelTransform::TransformVector
OutputVnlVectorType TransformVector(const InputVnlVectorType &) const override
Definition: itkKernelTransform.h:165
itk::KernelTransform::JacobianPositionType
typename Superclass::JacobianPositionType JacobianPositionType
Definition: itkKernelTransform.h:90
itk::KernelTransform::PointIdentifier
typename PointSetType::PointIdentifier PointIdentifier
Definition: itkKernelTransform.h:125
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::KernelTransform::m_SourceLandmarks
PointSetPointer m_SourceLandmarks
Definition: itkKernelTransform.h:386
itk::KernelTransform::m_Stiffness
double m_Stiffness
Definition: itkKernelTransform.h:340
itk::KernelTransform::PMatrixType
vnl_matrix< TParametersValueType > PMatrixType
Definition: itkKernelTransform.h:263
itk::KernelTransform::m_BVector
BMatrixType m_BVector
Definition: itkKernelTransform.h:372
itk::KernelTransform::AMatrixType
vnl_matrix_fixed< TParametersValueType, NDimensions, NDimensions > AMatrixType
Definition: itkKernelTransform.h:275
itk::KernelTransform::m_AMatrix
AMatrixType m_AMatrix
Definition: itkKernelTransform.h:369
itk::KernelTransform::m_DMatrix
DMatrixType m_DMatrix
Definition: itkKernelTransform.h:366
itk::KernelTransform::m_WMatrix
WMatrixType m_WMatrix
Definition: itkKernelTransform.h:359
itk::KernelTransform::GetTransformCategory
TransformCategoryEnum GetTransformCategory() const override
Definition: itkKernelTransform.h:227
itk::KernelTransform::ComputeJacobianWithRespectToPosition
void ComputeJacobianWithRespectToPosition(const InputPointType &, JacobianPositionType &) const override
Definition: itkKernelTransform.h:188
itk::KernelTransform::LMatrixType
vnl_matrix< TParametersValueType > LMatrixType
Definition: itkKernelTransform.h:257
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::PointSet::PointIdentifier
typename MeshTraits::PointIdentifier PointIdentifier
Definition: itkPointSet.h:105
itk::KernelTransform::TransformVector
OutputVectorType TransformVector(const InputVectorType &) const override
Definition: itkKernelTransform.h:158
itk::KernelTransform::m_TargetLandmarks
PointSetPointer m_TargetLandmarks
Definition: itkKernelTransform.h:389
itk::KernelTransform::OutputCovariantVectorType
typename Superclass::OutputCovariantVectorType OutputCovariantVectorType
Definition: itkKernelTransform.h:106
itk::KernelTransform::TransformCategoryEnum
typename Superclass::TransformCategoryEnum TransformCategoryEnum
Definition: itkKernelTransform.h:94
itk::KernelTransform::InputVectorType
typename Superclass::InputVectorType InputVectorType
Definition: itkKernelTransform.h:101
itk::KernelTransform::m_PMatrix
PMatrixType m_PMatrix
Definition: itkKernelTransform.h:353
itk::KernelTransform::JacobianType
typename Superclass::JacobianType JacobianType
Definition: itkKernelTransform.h:89
itk::KernelTransform::m_KMatrix
KMatrixType m_KMatrix
Definition: itkKernelTransform.h:350
itk::KernelTransform::ColumnMatrixType
vnl_matrix_fixed< TParametersValueType, NDimensions, 1 > ColumnMatrixType
Definition: itkKernelTransform.h:284
itk::KernelTransform::PointsContainer
typename PointSetType::PointsContainer PointsContainer
Definition: itkKernelTransform.h:122
itk::KernelTransform::OutputVectorType
typename Superclass::OutputVectorType OutputVectorType
Definition: itkKernelTransform.h:102
itk::KernelTransform::m_YMatrix
YMatrixType m_YMatrix
Definition: itkKernelTransform.h:356
itk::KernelTransform::m_Displacements
VectorSetPointer m_Displacements
Definition: itkKernelTransform.h:344
itk::KernelTransform::RowMatrixType
vnl_matrix_fixed< TParametersValueType, 1, NDimensions > RowMatrixType
Definition: itkKernelTransform.h:281
itk::KernelTransform::OutputVnlVectorType
typename Superclass::OutputVnlVectorType OutputVnlVectorType
Definition: itkKernelTransform.h:110
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itk::KernelTransform::OutputPointType
typename Superclass::OutputPointType OutputPointType
Definition: itkKernelTransform.h:98
itk::PointSet::PointsContainer
typename MeshTraits::PointsContainer PointsContainer
Definition: itkPointSet.h:107
itk::KernelTransform::m_LMatrix
LMatrixType m_LMatrix
Definition: itkKernelTransform.h:347
itk::KernelTransform::InputVnlVectorType
typename Superclass::InputVnlVectorType InputVnlVectorType
Definition: itkKernelTransform.h:109
itk::KernelTransform::FixedParametersType
typename Superclass::FixedParametersType FixedParametersType
Definition: itkKernelTransform.h:85
itk::KernelTransform::InputCovariantVectorType
typename Superclass::InputCovariantVectorType InputCovariantVectorType
Definition: itkKernelTransform.h:105
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::KernelTransform::GMatrixType
vnl_matrix_fixed< TParametersValueType, NDimensions, NDimensions > GMatrixType
Definition: itkKernelTransform.h:254
itk::KernelTransform::PointsIterator
typename PointSetType::PointsContainerIterator PointsIterator
Definition: itkKernelTransform.h:123
itk::KernelTransform::PointsConstIterator
typename PointSetType::PointsContainerConstIterator PointsConstIterator
Definition: itkKernelTransform.h:124
itk::KernelTransform::TransformCovariantVector
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const override
Definition: itkKernelTransform.h:173
itk::KernelTransform::WMatrixType
vnl_matrix< TParametersValueType > WMatrixType
Definition: itkKernelTransform.h:269
itk::KernelTransform
Definition: itkKernelTransform.h:61
itk::KernelTransform::VectorSetPointer
typename VectorSetType::Pointer VectorSetPointer
Definition: itkKernelTransform.h:129
itk::KernelTransform::NumberOfParametersType
typename Superclass::NumberOfParametersType NumberOfParametersType
Definition: itkKernelTransform.h:113
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
itkPointSet.h
itk::KernelTransform::InputPointType
typename Superclass::InputPointType InputPointType
Definition: itkKernelTransform.h:97
itkTransform.h
itk::KernelTransform::ParametersType
typename Superclass::ParametersType ParametersType
Definition: itkKernelTransform.h:86
itk::KernelTransform::DMatrixType
vnl_matrix< TParametersValueType > DMatrixType
Definition: itkKernelTransform.h:272
itk::PointSet::PointsContainerConstIterator
typename PointsContainer::ConstIterator PointsContainerConstIterator
Definition: itkPointSet.h:120
itk::KernelTransform::BMatrixType
vnl_vector_fixed< TParametersValueType, NDimensions > BMatrixType
Definition: itkKernelTransform.h:278
itk::VectorContainer
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.
Definition: itkVectorContainer.h:48
itk::KernelTransform::m_WMatrixComputed
bool m_WMatrixComputed
Definition: itkKernelTransform.h:380