ITK  4.8.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 
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();
141 
143  virtual OutputPointType TransformPoint(const InputPointType & thisPoint) const ITK_OVERRIDE;
144 
147  virtual OutputVectorType TransformVector(const InputVectorType &) const ITK_OVERRIDE
148  {
149  itkExceptionMacro( << "TransformVector(const InputVectorType &) is not implemented for KernelTransform");
150  }
152 
153  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const ITK_OVERRIDE
154  {
155  itkExceptionMacro( << "TransformVector(const InputVnlVectorType &) is not implemented for KernelTransform");
156  }
157 
161  {
162  itkExceptionMacro( << "TransformCovariantVector(const InputCovariantVectorType &) is not implemented for KernelTransform");
163  }
165 
167  typedef vnl_matrix_fixed<TParametersValueType, NDimensions, NDimensions> IMatrixType;
168 
170  virtual void ComputeJacobianWithRespectToParameters( const InputPointType & p, JacobianType & jacobian) const ITK_OVERRIDE;
171 
173  JacobianType &) const ITK_OVERRIDE
174  {
175  itkExceptionMacro( "ComputeJacobianWithRespectToPosition not yet implemented "
176  "for " << this->GetNameOfClass() );
177  }
178 
183  virtual void SetParameters(const ParametersType &) ITK_OVERRIDE;
184 
190  virtual void SetFixedParameters(const ParametersType &) ITK_OVERRIDE;
191 
193  virtual void UpdateParameters() const;
194 
196  virtual const ParametersType & GetParameters() const ITK_OVERRIDE;
197 
199  virtual const FixedParametersType & GetFixedParameters() const ITK_OVERRIDE;
200 
204  virtual TransformCategoryType GetTransformCategory() const ITK_OVERRIDE
205  {
206  return Self::Spline;
207  }
208 
219  itkSetClampMacro( Stiffness, double, 0.0, NumericTraits<double>::max() );
220  itkGetConstMacro(Stiffness, double);
222 
223 protected:
224  KernelTransform();
225  virtual ~KernelTransform();
226  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
227 
228 public:
230  typedef vnl_matrix_fixed<TParametersValueType, NDimensions, NDimensions> GMatrixType;
231 
233  typedef vnl_matrix<TParametersValueType> LMatrixType;
234 
236  typedef vnl_matrix<TParametersValueType> KMatrixType;
237 
239  typedef vnl_matrix<TParametersValueType> PMatrixType;
240 
242  typedef vnl_matrix<TParametersValueType> YMatrixType;
243 
245  typedef vnl_matrix<TParametersValueType> WMatrixType;
246 
248  typedef vnl_matrix<TParametersValueType> DMatrixType;
249 
251  typedef vnl_matrix_fixed<TParametersValueType, NDimensions, NDimensions> AMatrixType;
252 
254  typedef vnl_vector_fixed<TParametersValueType, NDimensions> BMatrixType;
255 
257  typedef vnl_matrix_fixed<TParametersValueType, 1, NDimensions> RowMatrixType;
258 
260  typedef vnl_matrix_fixed<TParametersValueType, NDimensions, 1> ColumnMatrixType;
261 
262 protected:
269  virtual void ComputeG(const InputVectorType & landmarkVector, GMatrixType & gmatrix) const;
270 
280  virtual const GMatrixType & ComputeReflexiveG(PointsIterator) const;
281 
284  virtual void ComputeDeformationContribution(const InputPointType & inputPoint, OutputPointType & result) const;
285 
287  void ComputeK();
288 
290  void ComputeL();
291 
293  void ComputeP();
294 
296  void ComputeY();
297 
299  void ComputeD();
300 
305  void ReorganizeW();
306 
308  double m_Stiffness;
309 
313 
316 
319 
322 
325 
328 
335 
338 
341 
346 
349 
352 
355 
358 
359 private:
360 
361  KernelTransform(const Self &); // purposely not implemented
362  void operator=(const Self &); // purposely not implemented
363 
364 };
365 } // end namespace itk
366 
367 #ifndef ITK_MANUAL_INSTANTIATION
368 #include "itkKernelTransform.hxx"
369 #endif
370 
371 #endif // itkKernelTransform_h
vnl_matrix< TParametersValueType > DMatrixType
PointSetPointer m_TargetLandmarks
PointSetType::PointIdentifier PointIdentifier
PointSetType::Pointer PointSetPointer
Light weight base class for most itk classes.
virtual void SetSourceLandmarks(PointSetType *)
PointSetType::PointsContainerIterator PointsIterator
Superclass::InputVectorType InputVectorType
Point< TParametersValueType, NInputDimensions > InputPointType
Definition: itkTransform.h:157
Superclass::InputPointType InputPointType
MeshTraits::PointIdentifier PointIdentifier
Definition: itkPointSet.h:105
virtual OutputVectorType TransformVector(const InputVectorType &) const
Definition: itkTransform.h:193
virtual void UpdateParameters() const
vnl_matrix< TParametersValueType > LMatrixType
CovariantVector< TParametersValueType, NOutputDimensions > OutputCovariantVectorType
Definition: itkTransform.h:150
vnl_vector_fixed< TParametersValueType, NOutputDimensions > OutputVnlVectorType
Definition: itkTransform.h:154
virtual void ComputeJacobianWithRespectToPosition(const InputPointType &, JacobianType &) const override
Point< TParametersValueType, NOutputDimensions > OutputPointType
Definition: itkTransform.h:158
PointSetType::PointsContainer PointsContainer
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const override
virtual ~KernelTransform()
virtual OutputVectorType TransformVector(const InputVectorType &) const override
virtual void ComputeG(const InputVectorType &landmarkVector, GMatrixType &gmatrix) const
vnl_matrix< TParametersValueType > YMatrixType
Superclass::ScalarType ScalarType
virtual TransformCategoryType GetTransformCategory() const override
vnl_matrix_fixed< TParametersValueType, NDimensions, 1 > ColumnMatrixType
virtual void SetTargetLandmarks(PointSetType *)
Superclass::ParametersType ParametersType
DefaultStaticMeshTraits< TParametersValueType, NDimensions, NDimensions, TParametersValueType, TParametersValueType > PointSetTraitsType
virtual const FixedParametersType & GetFixedParameters() 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
virtual void SetFixedParameters(const ParametersType &) override
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
void PrintSelf(std::ostream &os, Indent indent) const override
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
virtual OutputPointType TransformPoint(const InputPointType &thisPoint) const override
vnl_matrix_fixed< TParametersValueType, NDimensions, NDimensions > IMatrixType
Superclass::InputCovariantVectorType InputCovariantVectorType
vnl_matrix_fixed< TParametersValueType, NDimensions, NDimensions > AMatrixType
static const unsigned int SpaceDimension
virtual const char * GetNameOfClass() const
PointSet< InputPointType, NDimensions, PointSetTraitsType > PointSetType
virtual void ComputeJacobianWithRespectToParameters(const InputPointType &p, JacobianType &jacobian) const override
Superclass::JacobianType JacobianType
void operator=(const Self &)
VectorSetType::Pointer VectorSetPointer
Vector< TParametersValueType, NInputDimensions > InputVectorType
Definition: itkTransform.h:128
Define a front-end to the STL &quot;vector&quot; 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
virtual const ParametersType & GetParameters() const override
virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const override
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