Shapeworks Studio  2.1
Shape analysis software suite
itkCompactlySupportedRBFSparseKernelTransform.hxx
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkCompactlySupportedRBFSparseKernelTransform.txx,v $
5  Language: C++
6  Date: $Date: 2014-1-28 14:22:18 $
7  Version: $Revision: 1.1 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef _itkCompactlySupportedRBFSparseKernelTransform_txx
18 #define _itkCompactlySupportedRBFSparseKernelTransform_txx
19 #include "itkCompactlySupportedRBFSparseKernelTransform.h"
20 
21 namespace itk
22 {
23  template<class TScalarType, unsigned int NDimensions>
24  void CompactlySupportedRBFSparseKernelTransform<
25  TScalarType, NDimensions>::ComputeJacobianWithRespectToParameters(
26  const InputPointType & in, JacobianType & jacobian) const { }
27 
28  template <class TScalarType, unsigned int NDimensions>
31 ComputeG(const InputVectorType & x) const
32 {
33  double a = 3.0 * sqrt(3.14/2.0) * this->Sigma;
34 
35  const TScalarType r = (x.GetNorm())/a; // the support of the basis is only defined till 2.5*sigma
36  this->m_GMatrix = GMatrixType::Zero();
37 
38  if (r <= 1)
39  {
40  //this->m_GMatrix.fill( NumericTraits< TScalarType >::Zero );
41 
42  TScalarType val = pow(1-r, 4.0) * (4.0*r + 1);
43  for(unsigned int i=0; i<NDimensions; i++)
44  {
45  this->m_GMatrix(i,i) = val;
46 
47  //this->m_GMatrix[i][i] = val;
48  }
49  }
50  return this->m_GMatrix;
51 }
52 
53 
54 template <class TScalarType, unsigned int NDimensions>
55 void
58  OutputPointType & result ) const
59 {
60 
61  double a = 3.0 * sqrt(3.14/2.0) * this->Sigma;
62 
63  unsigned long numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints();
64 
65  PointsIterator sp = this->m_SourceLandmarks->GetPoints()->Begin();
66 
67  for(unsigned int lnd=0; lnd < numberOfLandmarks; lnd++ )
68  {
69  InputVectorType position = thisPoint - sp->Value();
70  const TScalarType r = (position.GetNorm())/a; // the support of the basis is only defined till 2.5*sigma
71 
72  TScalarType val = 0.0;
73  if(r <= 1)
74  val = pow(1-r, 4.0) * (4.0*r + 1);
75 
76  for(unsigned int odim=0; odim < NDimensions; odim++ )
77  {
78  result[ odim ] += val * this->m_DMatrix(odim,lnd);
79  }
80  ++sp;
81  }
82 
83 }
84 
85 
86 } // namespace itk
87 #endif
virtual void ComputeDeformationContribution(const InputPointType &inputPoint, OutputPointType &result) const
const GMatrixType & ComputeG(const InputVectorType &x) const