ITK  5.0.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 
32 namespace itk
33 {
59 template<typename TParametersValueType,
60  unsigned int NDimensions>
61 class ITK_TEMPLATE_EXPORT KernelTransform :
62  public Transform<TParametersValueType, NDimensions, NDimensions>
63 {
64 public:
65  ITK_DISALLOW_COPY_AND_ASSIGN(KernelTransform);
66 
72 
74  itkTypeMacro(KernelTransform, Transform);
75 
77  itkNewMacro(Self);
78 
80  static constexpr unsigned int SpaceDimension = NDimensions;
81 
83  using ScalarType = typename Superclass::ScalarType;
84 
86  using FixedParametersType = typename Superclass::FixedParametersType;
87  using ParametersType = typename Superclass::ParametersType;
88 
90  using JacobianType = typename Superclass::JacobianType;
91  using JacobianPositionType = typename Superclass::JacobianPositionType;
92  using InverseJacobianPositionType = typename Superclass::InverseJacobianPositionType;
93 
95  using TransformCategoryType = typename Superclass::TransformCategoryType;
96 
98  using InputPointType = typename Superclass::InputPointType;
99  using OutputPointType = typename Superclass::OutputPointType;
100 
102  using InputVectorType = typename Superclass::InputVectorType;
103  using OutputVectorType = typename Superclass::OutputVectorType;
104 
106  using InputCovariantVectorType = typename Superclass::InputCovariantVectorType;
107  using OutputCovariantVectorType = typename Superclass::OutputCovariantVectorType;
108 
110  using InputVnlVectorType = typename Superclass::InputVnlVectorType;
111  using OutputVnlVectorType = typename Superclass::OutputVnlVectorType;
112 
114  using NumberOfParametersType = typename Superclass::NumberOfParametersType;
115 
120 
126 
130 
132  itkGetModifiableObjectMacro(SourceLandmarks, PointSetType); //NOTE: This is used to circumvent the SetTargetLandmarks
133  virtual void SetSourceLandmarks(PointSetType *);
135 
137  itkGetModifiableObjectMacro(TargetLandmarks, PointSetType); //NOTE: This is used to circumvent the SetTargetLandmarks
138  virtual void SetTargetLandmarks(PointSetType *);
140 
143  itkGetModifiableObjectMacro(Displacements, VectorSetType);
144 
146  void ComputeWMatrix();
147 
149  OutputPointType TransformPoint(const InputPointType & thisPoint) const override;
150 
152  using Superclass::TransformVector;
154  {
155  itkExceptionMacro( << "TransformVector(const InputVectorType &) is not implemented for KernelTransform");
156  }
158 
160  {
161  itkExceptionMacro( << "TransformVector(const InputVnlVectorType &) is not implemented for KernelTransform");
162  }
163 
165  using Superclass::TransformCovariantVector;
167  {
168  itkExceptionMacro( << "TransformCovariantVector(const InputCovariantVectorType &) is not implemented for KernelTransform");
169  }
171 
173  using IMatrixType = vnl_matrix_fixed<TParametersValueType, NDimensions, NDimensions>;
174 
176  void ComputeJacobianWithRespectToParameters( const InputPointType & p, JacobianType & jacobian) const override;
177 
179  JacobianPositionType &) const override
180  {
181  itkExceptionMacro( "ComputeJacobianWithRespectToPosition not yet implemented "
182  "for " << this->GetNameOfClass() );
183  }
184  using Superclass::ComputeJacobianWithRespectToPosition;
185 
190  void SetParameters(const ParametersType &) override;
191 
197  void SetFixedParameters(const FixedParametersType &) override;
198 
200  virtual void UpdateParameters() const;
201 
203  const ParametersType & GetParameters() const override;
204 
206  const FixedParametersType & GetFixedParameters() const override;
207 
212  {
213  return Self::Spline;
214  }
215 
226  itkSetClampMacro( Stiffness, double, 0.0, NumericTraits<double>::max() );
227  itkGetConstMacro(Stiffness, double);
229 
230 protected:
231  KernelTransform();
232  ~KernelTransform() override = default;
233  void PrintSelf(std::ostream & os, Indent indent) const override;
234 
235 public:
237  using GMatrixType = vnl_matrix_fixed<TParametersValueType, NDimensions, NDimensions>;
238 
240  using LMatrixType = vnl_matrix<TParametersValueType>;
241 
243  using KMatrixType = vnl_matrix<TParametersValueType>;
244 
246  using PMatrixType = vnl_matrix<TParametersValueType>;
247 
249  using YMatrixType = vnl_matrix<TParametersValueType>;
250 
252  using WMatrixType = vnl_matrix<TParametersValueType>;
253 
255  using DMatrixType = vnl_matrix<TParametersValueType>;
256 
258  using AMatrixType = vnl_matrix_fixed<TParametersValueType, NDimensions, NDimensions>;
259 
261  using BMatrixType = vnl_vector_fixed<TParametersValueType, NDimensions>;
262 
264  using RowMatrixType = vnl_matrix_fixed<TParametersValueType, 1, NDimensions>;
265 
267  using ColumnMatrixType = vnl_matrix_fixed<TParametersValueType, NDimensions, 1>;
268 
269 protected:
276  virtual void ComputeG(const InputVectorType & landmarkVector, GMatrixType & gmatrix) const;
277 
287  virtual const GMatrixType & ComputeReflexiveG(PointsIterator) const;
288 
291  virtual void ComputeDeformationContribution(const InputPointType & inputPoint, OutputPointType & result) const;
292 
294  void ComputeK();
295 
297  void ComputeL();
298 
300  void ComputeP();
301 
303  void ComputeY();
304 
306  void ComputeD();
307 
312  void ReorganizeW();
313 
315  double m_Stiffness;
316 
320 
323 
326 
329 
332 
335 
342 
345 
348 
353 
356 
359 
362 
365 
366 private:
367 
368 };
369 } // end namespace itk
370 
371 #ifndef ITK_MANUAL_INSTANTIATION
372 #include "itkKernelTransform.hxx"
373 #endif
374 
375 #endif // itkKernelTransform_h
typename Superclass::InputVnlVectorType InputVnlVectorType
PointSetPointer m_TargetLandmarks
vnl_matrix< TParametersValueType > WMatrixType
Light weight base class for most itk classes.
typename Superclass::JacobianType JacobianType
typename Superclass::InputPointType InputPointType
vnl_matrix_fixed< TParametersValueType, NDimensions, NDimensions > GMatrixType
typename Superclass::OutputVectorType OutputVectorType
Define numeric traits for std::vector.
vnl_vector_fixed< TParametersValueType, NDimensions > BMatrixType
typename PointSetType::PointsContainerConstIterator PointsConstIterator
typename PointSetType::PointsContainerIterator PointsIterator
vnl_matrix< TParametersValueType > LMatrixType
vnl_matrix_fixed< TParametersValueType, NDimensions, NDimensions > AMatrixType
typename PointsContainer::ConstIterator PointsContainerConstIterator
Definition: itkPointSet.h:122
void ComputeJacobianWithRespectToPosition(const InputPointType &, JacobianPositionType &) const override
typename Superclass::OutputPointType OutputPointType
vnl_matrix_fixed< TParametersValueType, 1, NDimensions > RowMatrixType
typename PointSetType::Pointer PointSetPointer
typename Superclass::InputCovariantVectorType InputCovariantVectorType
vnl_matrix_fixed< TParametersValueType, NDimensions, NDimensions > IMatrixType
typename PointSetType::PointsContainer PointsContainer
typename Superclass::NumberOfParametersType NumberOfParametersType
typename Superclass::ScalarType ScalarType
OutputVnlVectorType TransformVector(const InputVnlVectorType &) const override
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:83
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const override
typename MeshTraits::PointsContainer PointsContainer
Definition: itkPointSet.h:109
PointSetPointer m_SourceLandmarks
OutputVectorType TransformVector(const InputVectorType &) const override
vnl_matrix< TParametersValueType > PMatrixType
typename Superclass::FixedParametersType FixedParametersType
typename Superclass::ParametersType ParametersType
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:84
typename PointsContainer::Iterator PointsContainerIterator
Definition: itkPointSet.h:123
typename PointSetType::PointIdentifier PointIdentifier
typename VectorSetType::Pointer VectorSetPointer
vnl_matrix< TParametersValueType > DMatrixType
typename Superclass::InputVectorType InputVectorType
vnl_matrix< TParametersValueType > YMatrixType
Define a front-end to the STL &quot;vector&quot; container that conforms to the IndexedContainerInterface.
typename MeshTraits::PointIdentifier PointIdentifier
Definition: itkPointSet.h:107
Control indentation during Print() invocation.
Definition: itkIndent.h:49
TransformCategoryType GetTransformCategory() const override
VectorSetPointer m_Displacements
vnl_matrix< TParametersValueType > KMatrixType
typename Superclass::OutputCovariantVectorType OutputCovariantVectorType
typename Superclass::OutputVnlVectorType OutputVnlVectorType
vnl_matrix_fixed< TParametersValueType, NDimensions, 1 > ColumnMatrixType
typename Superclass::InverseJacobianPositionType InverseJacobianPositionType
typename Superclass::JacobianPositionType JacobianPositionType