ITK  5.4.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
32namespace itk
33{
60template <typename TParametersValueType, unsigned int VDimension>
61class ITK_TEMPLATE_EXPORT KernelTransform : public Transform<TParametersValueType, VDimension, VDimension>
62{
63public:
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;
91 using typename Superclass::InverseJacobianPositionType;
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
105 using typename Superclass::InputCovariantVectorType;
106 using typename Superclass::OutputCovariantVectorType;
107
109 using typename Superclass::InputVnlVectorType;
110 using typename Superclass::OutputVnlVectorType;
111
113 using typename Superclass::NumberOfParametersType;
114
120
126
130
132 itkGetModifiableObjectMacro(SourceLandmarks, PointSetType); // NOTE: This is used to circumvent the SetTargetLandmarks
133 virtual void
138 itkGetModifiableObjectMacro(TargetLandmarks, PointSetType); // NOTE: This is used to circumvent the SetTargetLandmarks
139 virtual void
145 itkGetModifiableObjectMacro(Displacements, VectorSetType);
146
148 void
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
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
210
212 virtual void
214
216 const ParametersType &
217 GetParameters() const override;
218
220 const FixedParametersType &
221 GetFixedParameters() const override;
222
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);
246protected:
248 ~KernelTransform() override = default;
249 void
250 PrintSelf(std::ostream & os, Indent indent) const override;
251
252public:
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
286protected:
293 virtual void
294 ComputeG(const InputVectorType & landmarkVector, GMatrixType & gmatrix) const;
295
306
309 virtual void
311
313 void
315
317 void
319
321 void
323
325 void
327
329 void
331
336 void
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
384
386 PointSetPointer m_SourceLandmarks{};
387
389 PointSetPointer m_TargetLandmarks{};
390
391private:
392};
393} // end namespace itk
394
395#ifndef ITK_MANUAL_INSTANTIATION
396# include "itkKernelTransform.hxx"
397#endif
398
399#endif // itkKernelTransform_h
Array2D class representing a 2D array.
Definition: itkArray2D.h:43
A templated class holding a n-Dimensional covariant vector.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
typename VectorSetType::Pointer VectorSetPointer
virtual void SetSourceLandmarks(PointSetType *)
void SetFixedParameters(const FixedParametersType &) override
vnl_matrix_fixed< TParametersValueType, VDimension, VDimension > GMatrixType
const FixedParametersType & GetFixedParameters() const override
typename PointSetType::PointsContainerIterator PointsIterator
vnl_matrix< TParametersValueType > YMatrixType
OutputVnlVectorType TransformVector(const InputVnlVectorType &) const override
TransformCategoryEnum GetTransformCategory() const override
vnl_vector_fixed< TParametersValueType, VDimension > BMatrixType
vnl_matrix< TParametersValueType > PMatrixType
vnl_matrix_fixed< TParametersValueType, 1, VDimension > RowMatrixType
typename PointSetType::PointsContainer PointsContainer
virtual const GMatrixType & ComputeReflexiveG(PointsIterator) const
vnl_matrix< TParametersValueType > DMatrixType
const ParametersType & GetParameters() const override
typename PointSetType::Pointer PointSetPointer
typename PointSetType::PointsContainerConstIterator PointsConstIterator
virtual void ComputeG(const InputVectorType &landmarkVector, GMatrixType &gmatrix) const
virtual void ComputeDeformationContribution(const InputPointType &thisPoint, OutputPointType &result) const
vnl_matrix< TParametersValueType > WMatrixType
void SetParameters(const ParametersType &) override
vnl_matrix< TParametersValueType > LMatrixType
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const override
~KernelTransform() override=default
vnl_matrix_fixed< TParametersValueType, VDimension, VDimension > IMatrixType
vnl_matrix< TParametersValueType > KMatrixType
typename PointSetType::PointIdentifier PointIdentifier
void ComputeJacobianWithRespectToParameters(const InputPointType &p, JacobianType &jacobian) const override
virtual void UpdateParameters() const
void PrintSelf(std::ostream &os, Indent indent) const override
OutputPointType TransformPoint(const InputPointType &thisPoint) const override
void ComputeJacobianWithRespectToPosition(const InputPointType &, JacobianPositionType &) const override
virtual void SetTargetLandmarks(PointSetType *)
vnl_matrix_fixed< TParametersValueType, VDimension, VDimension > AMatrixType
vnl_matrix_fixed< TParametersValueType, VDimension, 1 > ColumnMatrixType
OutputVectorType TransformVector(const InputVectorType &) const override
Light weight base class for most itk classes.
Define additional traits for native types such as int or float.
Class to hold and manage different parameter types used during optimization.
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:83
typename PointsContainer::Iterator PointsContainerIterator
Definition: itkPointSet.h:125
typename PointsContainer::ConstIterator PointsContainerConstIterator
Definition: itkPointSet.h:124
typename MeshTraits::PointsContainer PointsContainer
Definition: itkPointSet.h:107
typename MeshTraits::PointIdentifier PointIdentifier
Definition: itkPointSet.h:105
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:54
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:84
vnl_vector_fixed< TParametersValueType, VInputDimension > InputVnlVectorType
Definition: itkTransform.h:170
vnl_matrix_fixed< ParametersValueType, VOutputDimension, VInputDimension > JacobianPositionType
Definition: itkTransform.h:145
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:63
const char * GetNameOfClass() const override
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....