ITK  6.0.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  * https://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 VDimension>
61 class ITK_TEMPLATE_EXPORT KernelTransform : public Transform<TParametersValueType, VDimension, VDimension>
62 {
63 public:
64  ITK_DISALLOW_COPY_AND_MOVE(KernelTransform);
65 
71 
73  itkOverrideGetNameOfClassMacro(KernelTransform);
74 
76  itkNewMacro(Self);
77 
79  static constexpr unsigned int SpaceDimension = VDimension;
80 
82  using typename Superclass::ScalarType;
83 
85  using typename Superclass::FixedParametersType;
86  using typename Superclass::ParametersType;
87 
89  using typename Superclass::JacobianType;
90  using typename Superclass::JacobianPositionType;
92 
94  using typename Superclass::TransformCategoryEnum;
95 
97  using typename Superclass::InputPointType;
98  using typename Superclass::OutputPointType;
99 
101  using typename Superclass::InputVectorType;
102  using typename Superclass::OutputVectorType;
103 
107 
109  using typename Superclass::InputVnlVectorType;
110  using typename Superclass::OutputVnlVectorType;
111 
113  using 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 *);
138  itkGetModifiableObjectMacro(TargetLandmarks, PointSetType); // NOTE: This is used to circumvent the SetTargetLandmarks
139  virtual void
140  SetTargetLandmarks(PointSetType *);
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  }
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  }
181  using IMatrixType = vnl_matrix_fixed<TParametersValueType, VDimension, VDimension>;
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);
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, VDimension, VDimension>;
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, VDimension, VDimension>;
276 
278  using BMatrixType = vnl_vector_fixed<TParametersValueType, VDimension>;
279 
281  using RowMatrixType = vnl_matrix_fixed<TParametersValueType, 1, VDimension>;
282 
284  using ColumnMatrixType = vnl_matrix_fixed<TParametersValueType, VDimension, 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 
344  VectorSetPointer m_Displacements{};
345 
347  LMatrixType m_LMatrix{};
348 
350  KMatrixType m_KMatrix{};
351 
353  PMatrixType m_PMatrix{};
354 
356  YMatrixType m_YMatrix{};
357 
359  WMatrixType m_WMatrix{};
360 
366  DMatrixType m_DMatrix{};
367 
369  AMatrixType m_AMatrix{};
370 
372  BMatrixType m_BVector{};
373 
377  mutable GMatrixType m_GMatrix{};
378 
380  bool m_WMatrixComputed{};
381 
383  IMatrixType m_I{};
384 
386  PointSetPointer m_SourceLandmarks{};
387 
389  PointSetPointer m_TargetLandmarks{};
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::GMatrixType
vnl_matrix_fixed< TParametersValueType, VDimension, VDimension > GMatrixType
Definition: itkKernelTransform.h:254
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::KernelTransform::RowMatrixType
vnl_matrix_fixed< TParametersValueType, 1, VDimension > RowMatrixType
Definition: itkKernelTransform.h:281
itk::KernelTransform::LMatrixType
vnl_matrix< TParametersValueType > LMatrixType
Definition: itkKernelTransform.h:257
itk::KernelTransform::TransformVector
OutputVectorType TransformVector(const InputVectorType &) const override
Definition: itkKernelTransform.h:158
itk::KernelTransform::PointSetPointer
typename PointSetType::Pointer PointSetPointer
Definition: itkKernelTransform.h:121
itk::DefaultStaticMeshTraits
Definition: itkDefaultStaticMeshTraits.h:61
GetNameOfClass
const char * GetNameOfClass() const override
itk::detail::VectorContainer
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.
Definition: itkVectorContainer.h:51
itk::PointSet
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:81
itk::KernelTransform::PointsIterator
typename PointSetType::PointsContainerIterator PointsIterator
Definition: itkKernelTransform.h:123
itkMatrix.h
itk::Transform< TParametersValueType, VDimension, VDimension >::OutputVnlVectorType
vnl_vector_fixed< TParametersValueType, VOutputDimension > OutputVnlVectorType
Definition: itkTransform.h:157
itk::KernelTransform::IMatrixType
vnl_matrix_fixed< TParametersValueType, VDimension, VDimension > IMatrixType
Definition: itkKernelTransform.h:181
itk::Vector
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
itk::KernelTransform::BMatrixType
vnl_vector_fixed< TParametersValueType, VDimension > BMatrixType
Definition: itkKernelTransform.h:278
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::KernelTransform::DMatrixType
vnl_matrix< TParametersValueType > DMatrixType
Definition: itkKernelTransform.h:272
itk::PointSetBase< TMeshTraits::PointsContainer >::PointsContainerIterator
typename PointsContainer::Iterator PointsContainerIterator
Definition: itkPointSetBase.h:91
itk::PointSetBase< TMeshTraits::PointsContainer >::PointsContainer
TMeshTraits::PointsContainer PointsContainer
Definition: itkPointSetBase.h:76
itk::KernelTransform::PointIdentifier
typename PointSetType::PointIdentifier PointIdentifier
Definition: itkKernelTransform.h:125
itk::KernelTransform::ComputeJacobianWithRespectToPosition
void ComputeJacobianWithRespectToPosition(const InputPointType &, JacobianPositionType &) const override
Definition: itkKernelTransform.h:188
itk::KernelTransform::PMatrixType
vnl_matrix< TParametersValueType > PMatrixType
Definition: itkKernelTransform.h:263
itk::PointSet::PointIdentifier
typename MeshTraits::PointIdentifier PointIdentifier
Definition: itkPointSet.h:103
itk::KernelTransform::YMatrixType
vnl_matrix< TParametersValueType > YMatrixType
Definition: itkKernelTransform.h:266
itk::KernelTransform::TransformVector
OutputVnlVectorType TransformVector(const InputVnlVectorType &) const override
Definition: itkKernelTransform.h:165
itk::Transform< TParametersValueType, VDimension, VDimension >::ScalarType
ParametersValueType ScalarType
Definition: itkTransform.h:127
itk::KernelTransform::AMatrixType
vnl_matrix_fixed< TParametersValueType, VDimension, VDimension > AMatrixType
Definition: itkKernelTransform.h:275
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:60
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:70
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::Transform< TParametersValueType, VDimension, VDimension >::JacobianPositionType
vnl_matrix_fixed< ParametersValueType, VOutputDimension, VInputDimension > JacobianPositionType
Definition: itkTransform.h:131
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::PointSetBase< TMeshTraits::PointsContainer >::PointsContainerConstIterator
typename PointsContainer::ConstIterator PointsContainerConstIterator
Definition: itkPointSetBase.h:90
itk::KernelTransform::GetTransformCategory
TransformCategoryEnum GetTransformCategory() const override
Definition: itkKernelTransform.h:227
itk::KernelTransform::PointsConstIterator
typename PointSetType::PointsContainerConstIterator PointsConstIterator
Definition: itkKernelTransform.h:124
itk::Transform< TParametersValueType, VDimension, VDimension >::InverseJacobianPositionType
vnl_matrix_fixed< ParametersValueType, VInputDimension, VOutputDimension > InverseJacobianPositionType
Definition: itkTransform.h:132
itk::KernelTransform::KMatrixType
vnl_matrix< TParametersValueType > KMatrixType
Definition: itkKernelTransform.h:260
itk::Point
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:53
itk::KernelTransform
Definition: itkKernelTransform.h:61
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:83
itkPointSet.h
itkTransform.h
itk::Array2D
Array2D class representing a 2D array.
Definition: itkArray2D.h:42
itk::KernelTransform::PointsContainer
typename PointSetType::PointsContainer PointsContainer
Definition: itkKernelTransform.h:122
itk::KernelTransform::ColumnMatrixType
vnl_matrix_fixed< TParametersValueType, VDimension, 1 > ColumnMatrixType
Definition: itkKernelTransform.h:284
itk::KernelTransform::VectorSetPointer
typename VectorSetType::Pointer VectorSetPointer
Definition: itkKernelTransform.h:129
itk::Transform< TParametersValueType, VDimension, VDimension >::InputVnlVectorType
vnl_vector_fixed< TParametersValueType, VInputDimension > InputVnlVectorType
Definition: itkTransform.h:156