ITK  4.6.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 TScalar, // probably only float and double make sense here
61  unsigned int NDimensions >
62 // Number of dimensions
64  public Transform< TScalar, NDimensions, NDimensions >
65 {
66 public:
72 
74  itkTypeMacro(KernelTransform, Transform);
75 
77  itkNewMacro(Self);
78 
80  itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
81 
84 
87 
90 
93 
97 
101 
105 
109 
114 
120 
124 
126  itkGetModifiableObjectMacro(SourceLandmarks, PointSetType); //NOTE: This is used to circumvent the SetTargetLandmarks
127  virtual void SetSourceLandmarks(PointSetType *);
129 
131  itkGetModifiableObjectMacro(TargetLandmarks, PointSetType); //NOTE: This is used to circumvent the SetTargetLandmarks
132  virtual void SetTargetLandmarks(PointSetType *);
134 
137  itkGetModifiableObjectMacro(Displacements, VectorSetType);
138 
140  void ComputeWMatrix(void);
141 
143  virtual OutputPointType TransformPoint(const InputPointType & thisPoint) const;
144 
148  { \
149  itkExceptionMacro( \
150  << "TransformVector(const InputVectorType &) is not implemented for KernelTransform"); \
151  }
153 
155  { \
156  itkExceptionMacro( \
157  << "TransformVector(const InputVnlVectorType &) is not implemented for KernelTransform"); \
158  }
159 
163  { \
164  itkExceptionMacro( \
165  << "TransformCovariantVector(const InputCovariantVectorType &) is not implemented for KernelTransform"); \
166  }
168 
170  typedef vnl_matrix_fixed<TScalar, NDimensions, NDimensions> IMatrixType;
171 
173  virtual void ComputeJacobianWithRespectToParameters( const InputPointType & p, JacobianType & jacobian) const;
174 
176  JacobianType &) const \
177  { \
178  itkExceptionMacro( "ComputeJacobianWithRespectToPosition not yet implemented " \
179  "for " << this->GetNameOfClass() ); \
180  }
181 
186  virtual void SetParameters(const ParametersType &);
187 
193  virtual void SetFixedParameters(const ParametersType &);
194 
196  virtual void UpdateParameters(void) const;
197 
199  virtual const ParametersType & GetParameters(void) const;
200 
202  virtual const ParametersType & GetFixedParameters(void) const;
203 
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;
230 
231 public:
233  typedef vnl_matrix_fixed<TScalar, NDimensions, NDimensions> GMatrixType;
234 
236  typedef vnl_matrix<TScalar> LMatrixType;
237 
239  typedef vnl_matrix<TScalar> KMatrixType;
240 
242  typedef vnl_matrix<TScalar> PMatrixType;
243 
245  typedef vnl_matrix<TScalar> YMatrixType;
246 
248  typedef vnl_matrix<TScalar> WMatrixType;
249 
251  typedef vnl_matrix<TScalar> DMatrixType;
252 
254  typedef vnl_matrix_fixed<TScalar, NDimensions, NDimensions> AMatrixType;
255 
257  typedef vnl_vector_fixed<TScalar, NDimensions> BMatrixType;
258 
260  typedef vnl_matrix_fixed<TScalar, 1, NDimensions> RowMatrixType;
261 
263  typedef vnl_matrix_fixed<TScalar, 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(void);
309 
311  double m_Stiffness;
312 
316 
319 
322 
325 
328 
331 
338 
341 
344 
349 
352 
355 
358 
361 
362 private:
363 
364  KernelTransform(const Self &); // purposely not implemented
365  void operator=(const Self &); // purposely not implemented
366 
367 };
368 } // end namespace itk
369 
370 #ifndef ITK_MANUAL_INSTANTIATION
371 #include "itkKernelTransform.hxx"
372 #endif
373 
374 #endif // __itkKernelTransform_h
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
Definition: itkTransform.h:238
DefaultStaticMeshTraits< TScalar, NDimensions, NDimensions, TScalar, TScalar > PointSetTraitsType
vnl_matrix< TScalar > LMatrixType
PointSetPointer m_TargetLandmarks
Vector< TScalar, NInputDimensions > InputVectorType
Definition: itkTransform.h:126
vnl_vector_fixed< TScalar, NInputDimensions > InputVnlVectorType
Definition: itkTransform.h:151
virtual ~KernelTransform()
Light weight base class for most itk classes.
vnl_matrix_fixed< TScalar, 1, NDimensions > RowMatrixType
Vector< TScalar, NOutputDimensions > OutputVectorType
Definition: itkTransform.h:127
MeshTraits::PointIdentifier PointIdentifier
Definition: itkPointSet.h:105
virtual void SetTargetLandmarks(PointSetType *)
static const unsigned int SpaceDimension
itk::VectorContainer< SizeValueType, InputVectorType > VectorSetType
vnl_matrix< TScalar > DMatrixType
virtual const ParametersType & GetParameters(void) const
Superclass::OutputVectorType OutputVectorType
virtual void ComputeDeformationContribution(const InputPointType &inputPoint, OutputPointType &result) const
Superclass::JacobianType JacobianType
virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
Transform< TScalar, NDimensions, NDimensions > Superclass
Superclass::TransformCategoryType TransformCategoryType
SmartPointer< const Self > ConstPointer
Superclass::InputVnlVectorType InputVnlVectorType
vnl_matrix< TScalar > WMatrixType
VectorSetType::Pointer VectorSetPointer
Superclass::OutputVnlVectorType OutputVnlVectorType
virtual void ComputeJacobianWithRespectToPosition(const InputPointType &, JacobianType &) const
Point< TScalar, NInputDimensions > InputPointType
Definition: itkTransform.h:155
vnl_matrix< TScalar > KMatrixType
Superclass::InputVectorType InputVectorType
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
void ReorganizeW(void)
PointSetType::PointIdentifier PointIdentifier
PointSetType::PointsContainerConstIterator PointsConstIterator
void PrintSelf(std::ostream &os, Indent indent) const
virtual void SetParameters(const ParametersType &)
Superclass::ParametersType ParametersType
SmartPointer< Self > Pointer
vnl_matrix_fixed< TScalar, NDimensions, NDimensions > GMatrixType
vnl_matrix< TScalar > PMatrixType
virtual const ParametersType & GetFixedParameters(void) const
vnl_matrix_fixed< TScalar, NDimensions, 1 > ColumnMatrixType
CovariantVector< TScalar, NOutputDimensions > OutputCovariantVectorType
Definition: itkTransform.h:148
CovariantVector< TScalar, NInputDimensions > InputCovariantVectorType
Definition: itkTransform.h:146
PointsContainer::ConstIterator PointsContainerConstIterator
Definition: itkPointSet.h:121
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
PointSetType::PointsContainerIterator PointsIterator
void operator=(const Self &)
PointSetPointer m_SourceLandmarks
Superclass::InputPointType InputPointType
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:84
Superclass::ScalarType ScalarType
MeshTraits::PointsContainer PointsContainer
Definition: itkPointSet.h:107
void ComputeWMatrix(void)
Superclass::OutputCovariantVectorType OutputCovariantVectorType
vnl_matrix< TScalar > YMatrixType
VectorSetPointer m_Displacements
virtual OutputVectorType TransformVector(const InputVectorType &) const
Definition: itkTransform.h:192
PointSetType::Pointer PointSetPointer
virtual void ComputeG(const InputVectorType &landmarkVector, GMatrixType &gmatrix) const
PointSet< InputPointType, NDimensions, PointSetTraitsType > PointSetType
Point< TScalar, NOutputDimensions > OutputPointType
Definition: itkTransform.h:156
virtual void SetSourceLandmarks(PointSetType *)
Superclass::InputCovariantVectorType InputCovariantVectorType
virtual const GMatrixType & ComputeReflexiveG(PointsIterator) const
virtual OutputPointType TransformPoint(const InputPointType &thisPoint) const
Define a front-end to the STL &quot;vector&quot; container that conforms to the IndexedContainerInterface.
vnl_vector_fixed< TScalar, NDimensions > BMatrixType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
vnl_matrix_fixed< TScalar, NDimensions, NDimensions > IMatrixType
Superclass::TransformCategoryType TransformCategoryType
Definition: itkTransform.h:431
vnl_matrix_fixed< TScalar, NDimensions, NDimensions > AMatrixType
Superclass::OutputPointType OutputPointType
vnl_vector_fixed< TScalar, NOutputDimensions > OutputVnlVectorType
Definition: itkTransform.h:152
Define additional traits for native types such as int or float.
virtual const char * GetNameOfClass() const
PointSetType::PointsContainer PointsContainer
virtual TransformCategoryType GetTransformCategory() const
virtual void UpdateParameters(void) const
virtual void ComputeJacobianWithRespectToParameters(const InputPointType &p, JacobianType &jacobian) const
PointsContainer::Iterator PointsContainerIterator
Definition: itkPointSet.h:122
virtual OutputVectorType TransformVector(const InputVectorType &) const
virtual void SetFixedParameters(const ParametersType &)