ITK  4.7.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 >
63  public Transform< TScalar, NDimensions, NDimensions >
64 {
65 public:
71 
73  itkTypeMacro(KernelTransform, Transform);
74 
76  itkNewMacro(Self);
77 
79  itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
80 
83 
86 
89 
92 
96 
100 
104 
108 
113 
119 
123 
125  itkGetModifiableObjectMacro(SourceLandmarks, PointSetType); //NOTE: This is used to circumvent the SetTargetLandmarks
126  virtual void SetSourceLandmarks(PointSetType *);
128 
130  itkGetModifiableObjectMacro(TargetLandmarks, PointSetType); //NOTE: This is used to circumvent the SetTargetLandmarks
131  virtual void SetTargetLandmarks(PointSetType *);
133 
136  itkGetModifiableObjectMacro(Displacements, VectorSetType);
137 
139  void ComputeWMatrix();
140 
142  virtual OutputPointType TransformPoint(const InputPointType & thisPoint) const ITK_OVERRIDE;
143 
146  virtual OutputVectorType TransformVector(const InputVectorType &) const ITK_OVERRIDE
147  {
148  itkExceptionMacro( << "TransformVector(const InputVectorType &) is not implemented for KernelTransform");
149  }
151 
152  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const ITK_OVERRIDE
153  {
154  itkExceptionMacro( << "TransformVector(const InputVnlVectorType &) is not implemented for KernelTransform");
155  }
156 
160  {
161  itkExceptionMacro( << "TransformCovariantVector(const InputCovariantVectorType &) is not implemented for KernelTransform");
162  }
164 
166  typedef vnl_matrix_fixed<TScalar, NDimensions, NDimensions> IMatrixType;
167 
169  virtual void ComputeJacobianWithRespectToParameters( const InputPointType & p, JacobianType & jacobian) const;
170 
172  JacobianType &) const
173  {
174  itkExceptionMacro( "ComputeJacobianWithRespectToPosition not yet implemented "
175  "for " << this->GetNameOfClass() );
176  }
177 
182  virtual void SetParameters(const ParametersType &) ITK_OVERRIDE;
183 
189  virtual void SetFixedParameters(const ParametersType &) ITK_OVERRIDE;
190 
192  virtual void UpdateParameters() const;
193 
195  virtual const ParametersType & GetParameters() const;
196 
198  virtual const ParametersType & GetFixedParameters() const;
199 
204  {
205  return Self::Spline;
206  }
207 
218  itkSetClampMacro( Stiffness, double, 0.0, NumericTraits<double>::max() );
219  itkGetConstMacro(Stiffness, double);
221 
222 protected:
223  KernelTransform();
224  virtual ~KernelTransform();
225  void PrintSelf(std::ostream & os, Indent indent) const;
226 
227 public:
229  typedef vnl_matrix_fixed<TScalar, NDimensions, NDimensions> GMatrixType;
230 
232  typedef vnl_matrix<TScalar> LMatrixType;
233 
235  typedef vnl_matrix<TScalar> KMatrixType;
236 
238  typedef vnl_matrix<TScalar> PMatrixType;
239 
241  typedef vnl_matrix<TScalar> YMatrixType;
242 
244  typedef vnl_matrix<TScalar> WMatrixType;
245 
247  typedef vnl_matrix<TScalar> DMatrixType;
248 
250  typedef vnl_matrix_fixed<TScalar, NDimensions, NDimensions> AMatrixType;
251 
253  typedef vnl_vector_fixed<TScalar, NDimensions> BMatrixType;
254 
256  typedef vnl_matrix_fixed<TScalar, 1, NDimensions> RowMatrixType;
257 
259  typedef vnl_matrix_fixed<TScalar, NDimensions, 1> ColumnMatrixType;
260 
261 protected:
268  virtual void ComputeG(const InputVectorType & landmarkVector, GMatrixType & gmatrix) const;
269 
279  virtual const GMatrixType & ComputeReflexiveG(PointsIterator) const;
280 
283  virtual void ComputeDeformationContribution(const InputPointType & inputPoint, OutputPointType & result) const;
284 
286  void ComputeK();
287 
289  void ComputeL();
290 
292  void ComputeP();
293 
295  void ComputeY();
296 
298  void ComputeD();
299 
304  void ReorganizeW(void);
305 
307  double m_Stiffness;
308 
312 
315 
318 
321 
324 
327 
334 
337 
340 
345 
348 
351 
354 
357 
358 private:
359 
360  KernelTransform(const Self &); // purposely not implemented
361  void operator=(const Self &); // purposely not implemented
362 
363 };
364 } // end namespace itk
365 
366 #ifndef ITK_MANUAL_INSTANTIATION
367 #include "itkKernelTransform.hxx"
368 #endif
369 
370 #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
Superclass::OutputVectorType OutputVectorType
virtual void ComputeDeformationContribution(const InputPointType &inputPoint, OutputPointType &result) const
virtual void SetFixedParameters(const ParametersType &) ITK_OVERRIDE
Superclass::JacobianType JacobianType
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
virtual OutputPointType TransformPoint(const InputPointType &thisPoint) const ITK_OVERRIDE
void ReorganizeW(void)
PointSetType::PointIdentifier PointIdentifier
PointSetType::PointsContainerConstIterator PointsConstIterator
void PrintSelf(std::ostream &os, Indent indent) const
Superclass::ParametersType ParametersType
SmartPointer< Self > Pointer
vnl_matrix_fixed< TScalar, NDimensions, NDimensions > GMatrixType
vnl_matrix< TScalar > PMatrixType
vnl_matrix_fixed< TScalar, NDimensions, 1 > ColumnMatrixType
CovariantVector< TScalar, NOutputDimensions > OutputCovariantVectorType
Definition: itkTransform.h:148
CovariantVector< TScalar, NInputDimensions > InputCovariantVectorType
Definition: itkTransform.h:146
virtual const ParametersType & GetParameters() const
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 &)
virtual OutputVectorType TransformVector(const InputVectorType &) const ITK_OVERRIDE
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
Superclass::OutputCovariantVectorType OutputCovariantVectorType
vnl_matrix< TScalar > YMatrixType
VectorSetPointer m_Displacements
virtual OutputVectorType TransformVector(const InputVectorType &) const
Definition: itkTransform.h:192
PointSetType::Pointer PointSetPointer
virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const ITK_OVERRIDE
virtual void ComputeG(const InputVectorType &landmarkVector, GMatrixType &gmatrix) const
virtual const ParametersType & GetFixedParameters() const
PointSet< InputPointType, NDimensions, PointSetTraitsType > PointSetType
Point< TScalar, NOutputDimensions > OutputPointType
Definition: itkTransform.h:156
virtual void SetParameters(const ParametersType &) ITK_OVERRIDE
virtual void SetSourceLandmarks(PointSetType *)
Superclass::InputCovariantVectorType InputCovariantVectorType
virtual const GMatrixType & ComputeReflexiveG(PointsIterator) const
Define a front-end to the STL &quot;vector&quot; container that conforms to the IndexedContainerInterface.
virtual void UpdateParameters() const
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:437
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 ComputeJacobianWithRespectToParameters(const InputPointType &p, JacobianType &jacobian) const
PointsContainer::Iterator PointsContainerIterator
Definition: itkPointSet.h:122