go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkKernelTransform2.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
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/*=========================================================================
19
20Program: Insight Segmentation & Registration Toolkit
21Module: $RCSfile: itkKernelTransform2.h,v $
22Language: C++
23Date: $Date: 2006-11-28 14:22:18 $
24Version: $Revision: 1.1 $
25
26Copyright (c) Insight Software Consortium. All rights reserved.
27See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
28
29This software is distributed WITHOUT ANY WARRANTY; without even
30the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
31PURPOSE. See the above copyright notices for more information.
32
33=========================================================================*/
34#ifndef itkKernelTransform2_h
35#define itkKernelTransform2_h
36
38#include "itkPoint.h"
39#include "itkVector.h"
40#include "itkMatrix.h"
41#include "itkPointSet.h"
42#include <deque>
43#include <math.h>
44#include <vnl/vnl_matrix_fixed.h>
45#include <vnl/vnl_matrix.h>
46#include <vnl/vnl_vector.h>
47#include <vnl/vnl_vector_fixed.h>
48#include <vnl/vnl_sample.h>
49#include <vnl/algo/vnl_svd.h>
50#include <vnl/algo/vnl_qr.h>
51
52namespace itk
53{
54
94template <class TScalarType, // probably only float and double make sense here
95 unsigned int NDimensions>
96// Number of dimensions
97class ITK_TEMPLATE_EXPORT KernelTransform2 : public AdvancedTransform<TScalarType, NDimensions, NDimensions>
98{
99public:
101
105 using Pointer = SmartPointer<Self>;
106 using ConstPointer = SmartPointer<const Self>;
107
110
112 itkNewMacro(Self);
113
115 itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
116
118 using typename Superclass::ScalarType;
119 using typename Superclass::ParametersType;
120 using typename Superclass::NumberOfParametersType;
121 using typename Superclass::JacobianType;
122 using typename Superclass::InputPointType;
123 using typename Superclass::OutputPointType;
124 using typename Superclass::InputVectorType;
125 using typename Superclass::OutputVectorType;
126 using typename Superclass::InputCovariantVectorType;
127 using typename Superclass::OutputCovariantVectorType;
128 using typename Superclass::InputVnlVectorType;
129 using typename Superclass::OutputVnlVectorType;
130
133 using typename Superclass::SpatialJacobianType;
135 using typename Superclass::SpatialHessianType;
137 using typename Superclass::InternalMatrixType;
138
142 using PointSetTraitsType = DefaultStaticMeshTraits<TScalarType, NDimensions, NDimensions, TScalarType, TScalarType>;
143 using PointSetType = PointSet<InputPointType, NDimensions, PointSetTraitsType>;
144 using PointSetPointer = typename PointSetType::Pointer;
145 using PointsContainer = typename PointSetType::PointsContainer;
146 using PointsIterator = typename PointSetType::PointsContainerIterator;
147 using PointsConstIterator = typename PointSetType::PointsContainerConstIterator;
148
150 using VectorSetType = VectorContainer<unsigned long, InputVectorType>;
151 using VectorSetPointer = typename VectorSetType::Pointer;
152
154 using IMatrixType = vnl_matrix_fixed<TScalarType, NDimensions, NDimensions>;
155
157 NumberOfParametersType
158 GetNumberOfParameters() const override
159 {
160 return (this->m_SourceLandmarks->GetNumberOfPoints() * SpaceDimension);
161 }
162
163
166
168 virtual void
170
173
175 virtual void
177
182
184 void
186
188 void
190
192 OutputPointType
193 TransformPoint(const InputPointType & thisPoint) const override;
194
196 OutputVectorType
197 TransformVector(const InputVectorType &) const override
198 {
199 itkExceptionMacro("TransformVector(const InputVectorType &) is not implemented for KernelTransform");
200 }
201
202
203 OutputVnlVectorType
204 TransformVector(const InputVnlVectorType &) const override
205 {
206 itkExceptionMacro("TransformVector(const InputVnlVectorType &) is not implemented for KernelTransform");
207 }
208
209
210 OutputCovariantVectorType
211 TransformCovariantVector(const InputCovariantVectorType &) const override
212 {
213 itkExceptionMacro(
214 "TransformCovariantVector(const InputCovariantVectorType &) is not implemented for KernelTransform");
215 }
216
217
219 void
220 GetJacobian(const InputPointType &, JacobianType &, NonZeroJacobianIndicesType &) const override;
221
223 virtual void
225
231 void
232 SetParameters(const ParametersType &) override;
233
239 void
240 SetFixedParameters(const ParametersType &) override;
241
243 virtual void
245
247 const ParametersType &
248 GetParameters() const override;
249
251 const ParametersType &
252 GetFixedParameters() const override;
253
264 virtual void
265 SetStiffness(double stiffness)
266 {
267 this->m_Stiffness = stiffness > 0 ? stiffness : 0.0;
268 this->m_LMatrixComputed = false;
269 this->m_LInverseComputed = false;
270 this->m_WMatrixComputed = false;
271 }
272
273
274 itkGetConstMacro(Stiffness, double);
275
282 virtual void
283 SetAlpha(TScalarType itkNotUsed(Alpha))
284 {}
285
292 itkSetMacro(PoissonRatio, TScalarType);
293 virtual const TScalarType
295 {
296 return this->m_PoissonRatio;
297 }
298
299
301 itkSetMacro(MatrixInversionMethod, std::string);
302 itkGetConstReferenceMacro(MatrixInversionMethod, std::string);
303
305 void
306 GetSpatialJacobian(const InputPointType &, SpatialJacobianType &) const override
307 {
308 itkExceptionMacro("Not implemented for KernelTransform2");
309 }
310
311
312 void
313 GetSpatialHessian(const InputPointType &, SpatialHessianType &) const override
314 {
315 itkExceptionMacro("Not implemented for KernelTransform2");
316 }
317
318
319 void
320 GetJacobianOfSpatialJacobian(const InputPointType &,
322 NonZeroJacobianIndicesType &) const override
323 {
324 itkExceptionMacro("Not implemented for KernelTransform2");
325 }
326
327
328 void
329 GetJacobianOfSpatialJacobian(const InputPointType &,
332 NonZeroJacobianIndicesType &) const override
333 {
334 itkExceptionMacro("Not implemented for KernelTransform2");
335 }
336
337
338 void
339 GetJacobianOfSpatialHessian(const InputPointType &,
341 NonZeroJacobianIndicesType &) const override
342 {
343 itkExceptionMacro("Not implemented for KernelTransform2");
344 }
345
346
347 void
348 GetJacobianOfSpatialHessian(const InputPointType &,
351 NonZeroJacobianIndicesType &) const override
352 {
353 itkExceptionMacro("Not implemented for KernelTransform2");
354 }
355
356
357protected:
360 void
361 PrintSelf(std::ostream & os, Indent indent) const override;
362
363public:
365 using GMatrixType = vnl_matrix_fixed<TScalarType, NDimensions, NDimensions>;
366
368 using LMatrixType = vnl_matrix<TScalarType>;
369
371 using KMatrixType = vnl_matrix<TScalarType>;
372
374 using PMatrixType = vnl_matrix<TScalarType>;
375
377 using YMatrixType = vnl_matrix<TScalarType>;
378
380 using WMatrixType = vnl_matrix<TScalarType>;
381
383 using DMatrixType = vnl_matrix<TScalarType>;
384
386 using AMatrixType = vnl_matrix_fixed<TScalarType, NDimensions, NDimensions>;
387
389 using BMatrixType = vnl_vector_fixed<TScalarType, NDimensions>;
390
392 using RowMatrixType = vnl_matrix_fixed<TScalarType, 1, NDimensions>;
393
395 using ColumnMatrixType = vnl_matrix_fixed<TScalarType, NDimensions, 1>;
396
398 PointSetPointer m_SourceLandmarks{};
399
401 PointSetPointer m_TargetLandmarks{};
402
403protected:
411 virtual void
412 ComputeG(const InputVectorType & landmarkVector, GMatrixType & GMatrix) const;
413
421 virtual void
423
427 virtual void
428 ComputeDeformationContribution(const InputPointType & inputPoint, OutputPointType & result) const;
429
431 void
433
435 void
437
439 void
441
443 void
445
447 void
449
454 void
456
458 double m_Stiffness{};
459
463 VectorSetPointer m_Displacements{};
464
466 LMatrixType m_LMatrix{};
467
469 LMatrixType m_LMatrixInverse{};
470
472 KMatrixType m_KMatrix{};
473
475 PMatrixType m_PMatrix{};
476
478 YMatrixType m_YMatrix{};
479
481 WMatrixType m_WMatrix{};
482
488 DMatrixType m_DMatrix{};
489
491 AMatrixType m_AMatrix{};
492
494 BMatrixType m_BVector{};
495
501 // GMatrixType m_GMatrix;
502
504 bool m_WMatrixComputed{};
506 bool m_LMatrixComputed{};
508 bool m_LInverseComputed{};
510 bool m_LMatrixDecompositionComputed{};
511
518 using SVDDecompositionType = vnl_svd<ScalarType>;
519 using QRDecompositionType = vnl_qr<ScalarType>;
520
521 SVDDecompositionType * m_LMatrixDecompositionSVD{};
522 QRDecompositionType * m_LMatrixDecompositionQR{};
523
526
528 NonZeroJacobianIndicesType m_NonZeroJacobianIndices{};
529
533 bool m_FastComputationPossible{};
534
535private:
536 // Private using-declarations, to avoid `-Woverloaded-virtual` warnings from GCC (GCC 11.4).
537 using Superclass::TransformCovariantVector;
538 using Superclass::TransformVector;
539
540 TScalarType m_PoissonRatio{};
541
543 std::string m_MatrixInversionMethod{};
544};
545
546} // end namespace itk
547
548#ifndef ITK_MANUAL_INSTANTIATION
549# include "itkKernelTransform2.hxx"
550#endif
551
552#endif // itkKernelTransform2_h
Transform maps points, vectors and covariant vectors from an input space to an output space.
typename SpatialJacobianType::InternalMatrixType InternalMatrixType
FixedArray< Matrix< ScalarType, InputSpaceDimension, InputSpaceDimension >, OutputSpaceDimension > SpatialHessianType
Matrix< ScalarType, OutputSpaceDimension, InputSpaceDimension > SpatialJacobianType
typename PointSetType::Pointer PointSetPointer
void SetParameters(const ParametersType &) override
void GetSpatialHessian(const InputPointType &, SpatialHessianType &) const override
const ParametersType & GetFixedParameters() const override
virtual void ComputeG(const InputVectorType &landmarkVector, GMatrixType &GMatrix) const
virtual void SetAlpha(TScalarType)
virtual void SetStiffness(double stiffness)
DefaultStaticMeshTraits< TScalarType, NDimensions, NDimensions, TScalarType, TScalarType > PointSetTraitsType
ITK_DISALLOW_COPY_AND_MOVE(KernelTransform2)
const ParametersType & GetParameters() const override
virtual void SetIdentity()
OutputVnlVectorType TransformVector(const InputVnlVectorType &) const override
SmartPointer< const Self > ConstPointer
VectorContainer< unsigned long, InputVectorType > VectorSetType
itkGetModifiableObjectMacro(TargetLandmarks, PointSetType)
virtual void SetTargetLandmarks(PointSetType *)
OutputPointType TransformPoint(const InputPointType &thisPoint) const override
vnl_matrix_fixed< TScalarType, 1, NDimensions > RowMatrixType
vnl_matrix_fixed< TScalarType, NDimensions, 1 > ColumnMatrixType
NumberOfParametersType GetNumberOfParameters() const override
itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions)
virtual void UpdateParameters()
itkGetModifiableObjectMacro(SourceLandmarks, PointSetType)
void SetFixedParameters(const ParametersType &) override
void PrintSelf(std::ostream &os, Indent indent) const override
typename PointSetType::PointsContainer PointsContainer
void GetJacobianOfSpatialHessian(const InputPointType &, JacobianOfSpatialHessianType &, NonZeroJacobianIndicesType &) const override
void GetJacobianOfSpatialJacobian(const InputPointType &, JacobianOfSpatialJacobianType &, NonZeroJacobianIndicesType &) const override
~KernelTransform2() override
void GetJacobianOfSpatialHessian(const InputPointType &, SpatialHessianType &, JacobianOfSpatialHessianType &, NonZeroJacobianIndicesType &) const override
vnl_svd< ScalarType > SVDDecompositionType
virtual void ComputeDeformationContribution(const InputPointType &inputPoint, OutputPointType &result) const
void GetJacobianOfSpatialJacobian(const InputPointType &, SpatialJacobianType &, JacobianOfSpatialJacobianType &, NonZeroJacobianIndicesType &) const override
virtual const TScalarType GetPoissonRatio() const
typename PointSetType::PointsContainerIterator PointsIterator
virtual void SetSourceLandmarks(PointSetType *)
void GetSpatialJacobian(const InputPointType &, SpatialJacobianType &) const override
typename PointSetType::PointsContainerConstIterator PointsConstIterator
typename VectorSetType::Pointer VectorSetPointer
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const override
itkGetModifiableObjectMacro(Displacements, VectorSetType)
PointSet< InputPointType, NDimensions, PointSetTraitsType > PointSetType
virtual void ComputeReflexiveG(PointsIterator, GMatrixType &GMatrix) const
vnl_qr< ScalarType > QRDecompositionType
void GetJacobian(const InputPointType &, JacobianType &, NonZeroJacobianIndicesType &) const override
OutputVectorType TransformVector(const InputVectorType &) const override


Generated on 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo