ITK  4.10.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 #include "vnl/vnl_sample.h"
32 
33 namespace itk
34 {
60 template<typename TParametersValueType,
61  unsigned int NDimensions>
63  public Transform<TParametersValueType, NDimensions, NDimensions>
64 {
65 public:
71 
73  itkTypeMacro(KernelTransform, Transform);
74 
76  itkNewMacro(Self);
77 
79  itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
80 
83 
87 
90 
93 
97 
101 
105 
109 
112 
117 
123 
127 
129  itkGetModifiableObjectMacro(SourceLandmarks, PointSetType); //NOTE: This is used to circumvent the SetTargetLandmarks
130  virtual void SetSourceLandmarks(PointSetType *);
132 
134  itkGetModifiableObjectMacro(TargetLandmarks, PointSetType); //NOTE: This is used to circumvent the SetTargetLandmarks
135  virtual void SetTargetLandmarks(PointSetType *);
137 
140  itkGetModifiableObjectMacro(Displacements, VectorSetType);
141 
143  void ComputeWMatrix();
144 
146  virtual OutputPointType TransformPoint(const InputPointType & thisPoint) const ITK_OVERRIDE;
147 
150  virtual OutputVectorType TransformVector(const InputVectorType &) const ITK_OVERRIDE
151  {
152  itkExceptionMacro( << "TransformVector(const InputVectorType &) is not implemented for KernelTransform");
153  }
155 
156  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const ITK_OVERRIDE
157  {
158  itkExceptionMacro( << "TransformVector(const InputVnlVectorType &) is not implemented for KernelTransform");
159  }
160 
163  virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const ITK_OVERRIDE
164  {
165  itkExceptionMacro( << "TransformCovariantVector(const InputCovariantVectorType &) is not implemented for KernelTransform");
166  }
168 
170  typedef vnl_matrix_fixed<TParametersValueType, NDimensions, NDimensions> IMatrixType;
171 
173  virtual void ComputeJacobianWithRespectToParameters( const InputPointType & p, JacobianType & jacobian) const ITK_OVERRIDE;
174 
175  virtual void ComputeJacobianWithRespectToPosition(const InputPointType &,
176  JacobianType &) const ITK_OVERRIDE
177  {
178  itkExceptionMacro( "ComputeJacobianWithRespectToPosition not yet implemented "
179  "for " << this->GetNameOfClass() );
180  }
181 
186  virtual void SetParameters(const ParametersType &) ITK_OVERRIDE;
187 
193  virtual void SetFixedParameters(const FixedParametersType &) ITK_OVERRIDE;
194 
196  virtual void UpdateParameters() const;
197 
199  virtual const ParametersType & GetParameters() const ITK_OVERRIDE;
200 
202  virtual const FixedParametersType & GetFixedParameters() const ITK_OVERRIDE;
203 
207  virtual TransformCategoryType GetTransformCategory() const ITK_OVERRIDE
208  {
209  return Self::Spline;
210  }
211 
222  itkSetClampMacro( Stiffness, double, 0.0, NumericTraits<double>::max() );
223  itkGetConstMacro(Stiffness, double);
225 
226 protected:
227  KernelTransform();
228  virtual ~KernelTransform();
229  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
230 
231 public:
233  typedef vnl_matrix_fixed<TParametersValueType, NDimensions, NDimensions> GMatrixType;
234 
236  typedef vnl_matrix<TParametersValueType> LMatrixType;
237 
239  typedef vnl_matrix<TParametersValueType> KMatrixType;
240 
242  typedef vnl_matrix<TParametersValueType> PMatrixType;
243 
245  typedef vnl_matrix<TParametersValueType> YMatrixType;
246 
248  typedef vnl_matrix<TParametersValueType> WMatrixType;
249 
251  typedef vnl_matrix<TParametersValueType> DMatrixType;
252 
254  typedef vnl_matrix_fixed<TParametersValueType, NDimensions, NDimensions> AMatrixType;
255 
257  typedef vnl_vector_fixed<TParametersValueType, NDimensions> BMatrixType;
258 
260  typedef vnl_matrix_fixed<TParametersValueType, 1, NDimensions> RowMatrixType;
261 
263  typedef vnl_matrix_fixed<TParametersValueType, NDimensions, 1> ColumnMatrixType;
264 
265 protected:
272  virtual void ComputeG(const InputVectorType & landmarkVector, GMatrixType & gmatrix) const;
273 
283  virtual const GMatrixType & ComputeReflexiveG(PointsIterator) const;
284 
287  virtual void ComputeDeformationContribution(const InputPointType & inputPoint, OutputPointType & result) const;
288 
290  void ComputeK();
291 
293  void ComputeL();
294 
296  void ComputeP();
297 
299  void ComputeY();
300 
302  void ComputeD();
303 
308  void ReorganizeW();
309 
311  double m_Stiffness;
312 
315  VectorSetPointer m_Displacements;
316 
318  LMatrixType m_LMatrix;
319 
321  KMatrixType m_KMatrix;
322 
324  PMatrixType m_PMatrix;
325 
327  YMatrixType m_YMatrix;
328 
330  WMatrixType m_WMatrix;
331 
337  DMatrixType m_DMatrix;
338 
340  AMatrixType m_AMatrix;
341 
343  BMatrixType m_BVector;
344 
348  mutable GMatrixType m_GMatrix;
349 
352 
354  IMatrixType m_I;
355 
357  PointSetPointer m_SourceLandmarks;
358 
360  PointSetPointer m_TargetLandmarks;
361 
362 private:
363 
364  KernelTransform(const Self &) ITK_DELETE_FUNCTION;
365  void operator=(const Self &) ITK_DELETE_FUNCTION;
366 
367 };
368 } // end namespace itk
369 
370 #ifndef ITK_MANUAL_INSTANTIATION
371 #include "itkKernelTransform.hxx"
372 #endif
373 
374 #endif // itkKernelTransform_h
vnl_matrix< TParametersValueType > DMatrixType
PointSetPointer m_TargetLandmarks
PointSetType::PointIdentifier PointIdentifier
PointSetType::Pointer PointSetPointer
virtual void SetSourceLandmarks(PointSetType *)
PointSetType::PointsContainerIterator PointsIterator
Superclass::InputVectorType InputVectorType
virtual OutputVectorType TransformVector(const InputVectorType &) const override
Point< TParametersValueType, NInputDimensions > InputPointType
Definition: itkTransform.h:157
Superclass::InputPointType InputPointType
virtual TransformCategoryType GetTransformCategory() const override
MeshTraits::PointIdentifier PointIdentifier
Definition: itkPointSet.h:105
void PrintSelf(std::ostream &os, Indent indent) const override
virtual OutputVectorType TransformVector(const InputVectorType &) const
Definition: itkTransform.h:193
virtual void UpdateParameters() const
virtual void SetFixedParameters(const FixedParametersType &) override
vnl_matrix< TParametersValueType > LMatrixType
CovariantVector< TParametersValueType, NOutputDimensions > OutputCovariantVectorType
Definition: itkTransform.h:150
vnl_vector_fixed< TParametersValueType, NOutputDimensions > OutputVnlVectorType
Definition: itkTransform.h:154
Superclass::NumberOfParametersType NumberOfParametersType
Point< TParametersValueType, NOutputDimensions > OutputPointType
Definition: itkTransform.h:158
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes...
Definition: itkArray.h:30
virtual void ComputeJacobianWithRespectToPosition(const InputPointType &, JacobianType &) const override
PointSetType::PointsContainer PointsContainer
virtual ~KernelTransform()
virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const override
virtual void ComputeG(const InputVectorType &landmarkVector, GMatrixType &gmatrix) const
vnl_matrix< TParametersValueType > YMatrixType
Superclass::ScalarType ScalarType
vnl_matrix_fixed< TParametersValueType, NDimensions, 1 > ColumnMatrixType
virtual void SetTargetLandmarks(PointSetType *)
Superclass::ParametersType ParametersType
DefaultStaticMeshTraits< TParametersValueType, NDimensions, NDimensions, TParametersValueType, TParametersValueType > PointSetTraitsType
virtual const ParametersType & GetParameters() const override
Superclass::FixedParametersType FixedParametersType
vnl_matrix_fixed< TParametersValueType, 1, NDimensions > RowMatrixType
virtual void SetParameters(const ParametersType &) override
PointsContainer::ConstIterator PointsContainerConstIterator
Definition: itkPointSet.h:121
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
SmartPointer< const Self > ConstPointer
PointSetPointer m_SourceLandmarks
Superclass::OutputCovariantVectorType OutputCovariantVectorType
vnl_matrix< TParametersValueType > WMatrixType
Superclass::OutputVectorType OutputVectorType
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:84
vnl_matrix_fixed< TParametersValueType, NDimensions, NDimensions > GMatrixType
itk::VectorContainer< SizeValueType, InputVectorType > VectorSetType
MeshTraits::PointsContainer PointsContainer
Definition: itkPointSet.h:107
Superclass::OutputVnlVectorType OutputVnlVectorType
virtual void ComputeDeformationContribution(const InputPointType &inputPoint, OutputPointType &result) const
SmartPointer< Self > Pointer
Superclass::TransformCategoryType TransformCategoryType
vnl_vector_fixed< TParametersValueType, NInputDimensions > InputVnlVectorType
Definition: itkTransform.h:153
vnl_matrix< TParametersValueType > KMatrixType
vnl_matrix_fixed< TParametersValueType, NDimensions, NDimensions > IMatrixType
Superclass::InputCovariantVectorType InputCovariantVectorType
virtual OutputPointType TransformPoint(const InputPointType &thisPoint) const override
vnl_matrix_fixed< TParametersValueType, NDimensions, NDimensions > AMatrixType
static const unsigned int SpaceDimension
virtual const char * GetNameOfClass() const
PointSet< InputPointType, NDimensions, PointSetTraitsType > PointSetType
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const override
Superclass::JacobianType JacobianType
VectorSetType::Pointer VectorSetPointer
Vector< TParametersValueType, NInputDimensions > InputVectorType
Definition: itkTransform.h:128
virtual const FixedParametersType & GetFixedParameters() const override
virtual void ComputeJacobianWithRespectToParameters(const InputPointType &p, JacobianType &jacobian) const override
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.
PointSetType::PointsContainerConstIterator PointsConstIterator
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
Definition: itkTransform.h:239
vnl_matrix< TParametersValueType > PMatrixType
Vector< TParametersValueType, NOutputDimensions > OutputVectorType
Definition: itkTransform.h:129
VectorSetPointer m_Displacements
Transform< TParametersValueType, NDimensions, NDimensions > Superclass
Define additional traits for native types such as int or float.
Superclass::InputVnlVectorType InputVnlVectorType
PointsContainer::Iterator PointsContainerIterator
Definition: itkPointSet.h:122
CovariantVector< TParametersValueType, NInputDimensions > InputCovariantVectorType
Definition: itkTransform.h:148
Superclass::OutputPointType OutputPointType
virtual const GMatrixType & ComputeReflexiveG(PointsIterator) const
vnl_vector_fixed< TParametersValueType, NDimensions > BMatrixType