go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkAdvancedMatrixOffsetTransformBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright UMC Utrecht and contributors
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 
19 /*
20 
21  Program: Insight Segmentation & Registration Toolkit
22  Module: $RCSfile: itkAdvancedMatrixOffsetTransformBase.h,v $
23  Language: C++
24  Date: $Date: 2008-06-29 12:58:58 $
25  Version: $Revision: 1.20 $
26 
27  Copyright (c) Insight Software Consortium. All rights reserved.
28  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
29 
30  This software is distributed WITHOUT ANY WARRANTY; without even
31  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
32  PURPOSE. See the above copyright notices for more information.
33 
34 =========================================================================*/
35 #ifndef __itkAdvancedMatrixOffsetTransformBase_h
36 #define __itkAdvancedMatrixOffsetTransformBase_h
37 
38 #include <iostream>
39 
40 #include "itkMatrix.h"
41 #include "itkAdvancedTransform.h"
42 #include "itkExceptionObject.h"
43 #include "itkMacro.h"
44 
45 namespace itk
46 {
47 
92 template<
93 class TScalarType = double, // Data type for scalars
94 unsigned int NInputDimensions = 3, // Number of dimensions in the input space
95 unsigned int NOutputDimensions = 3 >
96 // Number of dimensions in the output space
98  public AdvancedTransform< TScalarType, NInputDimensions, NOutputDimensions >
99 {
100 public:
101 
104  typedef AdvancedTransform< TScalarType,
105  NInputDimensions, NOutputDimensions > Superclass;
107  typedef SmartPointer< const Self > ConstPointer;
108 
111 
113  itkNewMacro( Self );
114 
116  itkStaticConstMacro( InputSpaceDimension, unsigned int, NInputDimensions );
117  itkStaticConstMacro( OutputSpaceDimension, unsigned int, NOutputDimensions );
118  itkStaticConstMacro( ParametersDimension, unsigned int,
119  NOutputDimensions * ( NInputDimensions + 1 ) );
120 
128  typedef typename Superclass
130  typedef typename Superclass
136  typedef typename Superclass::TransformCategoryType TransformCategoryType;
137 
138  typedef typename Superclass
141  typedef typename Superclass
144  typedef typename Superclass
147 
149  typedef Matrix< TScalarType,
150  itkGetStaticConstMacro( OutputSpaceDimension ),
151  itkGetStaticConstMacro( InputSpaceDimension ) > MatrixType;
152 
154  typedef Matrix< TScalarType,
155  itkGetStaticConstMacro( InputSpaceDimension ),
156  itkGetStaticConstMacro( OutputSpaceDimension ) > InverseMatrixType;
157 
159  typedef InputPointType CenterType;
160  typedef OutputVectorType OffsetType;
161  typedef OutputVectorType TranslationType;
162 
166  virtual void SetIdentity( void );
167 
180  virtual void SetMatrix( const MatrixType & matrix )
181  {
182  this->m_Matrix = matrix;
183  this->ComputeOffset();
184  this->ComputeMatrixParameters();
185  this->m_MatrixMTime.Modified();
186  this->Modified();
187  }
188 
189 
197  const MatrixType & GetMatrix( void ) const
198  {
199  return this->m_Matrix;
200  }
201 
202 
212  void SetOffset( const OutputVectorType & offset )
213  {
214  this->m_Offset = offset;
215  this->ComputeTranslation();
216  this->Modified();
217  }
218 
219 
226  const OutputVectorType & GetOffset( void ) const
227  {
228  return this->m_Offset;
229  }
230 
231 
255  void SetCenter( const InputPointType & center )
256  {
257  this->m_Center = center;
258  this->ComputeOffset();
259  this->Modified();
260  }
261 
262 
270  const InputPointType & GetCenter( void ) const
271  {
272  return this->m_Center;
273  }
274 
275 
283  void SetTranslation( const OutputVectorType & translation )
284  {
285  this->m_Translation = translation;
286  this->ComputeOffset();
287  this->Modified();
288  }
289 
290 
298  const OutputVectorType & GetTranslation( void ) const
299  {
300  return this->m_Translation;
301  }
302 
303 
309  void SetParameters( const ParametersType & parameters );
310 
312  const ParametersType & GetParameters( void ) const;
313 
315  virtual void SetFixedParameters( const ParametersType & );
316 
318  virtual const ParametersType & GetFixedParameters( void ) const;
319 
332  void Compose( const Self * other, bool pre = 0 );
333 
342  OutputPointType TransformPoint( const InputPointType & point ) const;
343 
344  OutputVectorType TransformVector( const InputVectorType & vector ) const;
345 
346  OutputVnlVectorType TransformVector( const InputVnlVectorType & vector ) const;
347 
348  OutputCovariantVectorType TransformCovariantVector(
349  const InputCovariantVectorType & vector ) const;
350 
368  bool GetInverse( Self * inverse ) const;
369 
373  const InverseMatrixType & GetInverseMatrix( void ) const;
374 
380  virtual bool IsLinear( void ) const
381  {
382  return true;
383  }
384 
385 
389  virtual TransformCategoryType GetTransformCategory() const
390  {
391  return Self::Linear;
392  }
393 
394 
396  virtual void GetJacobian(
397  const InputPointType &,
398  JacobianType &,
399  NonZeroJacobianIndicesType & ) const;
400 
402  virtual void GetSpatialJacobian(
403  const InputPointType &,
404  SpatialJacobianType & ) const;
405 
407  virtual void GetSpatialHessian(
408  const InputPointType &,
409  SpatialHessianType & ) const;
410 
412  virtual void GetJacobianOfSpatialJacobian(
413  const InputPointType &,
414  JacobianOfSpatialJacobianType &,
415  NonZeroJacobianIndicesType & ) const;
416 
418  virtual void GetJacobianOfSpatialJacobian(
419  const InputPointType &,
420  SpatialJacobianType &,
421  JacobianOfSpatialJacobianType &,
422  NonZeroJacobianIndicesType & ) const;
423 
425  virtual void GetJacobianOfSpatialHessian(
426  const InputPointType &,
427  JacobianOfSpatialHessianType &,
428  NonZeroJacobianIndicesType & ) const;
429 
432  virtual void GetJacobianOfSpatialHessian(
433  const InputPointType & ipp,
434  SpatialHessianType & sh,
435  JacobianOfSpatialHessianType & jsh,
436  NonZeroJacobianIndicesType & nonZeroJacobianIndices ) const;
437 
438 protected:
439 
449  const OutputVectorType & offset );
450  AdvancedMatrixOffsetTransformBase( unsigned int paramDims );
452 
454  virtual void PrecomputeJacobians( unsigned int paramDims );
455 
458 
460  void PrintSelf( std::ostream & s, Indent indent ) const;
461 
463  {
464  return this->m_InverseMatrix;
465  }
466 
467 
468  void SetVarInverseMatrix( const InverseMatrixType & matrix ) const
469  {
470  this->m_InverseMatrix = matrix;
471  this->m_InverseMatrixMTime.Modified();
472  }
473 
474 
475  bool InverseMatrixIsOld( void ) const
476  {
477  if( this->m_MatrixMTime != this->m_InverseMatrixMTime )
478  {
479  return true;
480  }
481  else
482  {
483  return false;
484  }
485  }
486 
487 
488  virtual void ComputeMatrixParameters( void );
489 
490  virtual void ComputeMatrix( void );
491 
492  void SetVarMatrix( const MatrixType & matrix )
493  {
494  this->m_Matrix = matrix;
495  this->m_MatrixMTime.Modified();
496  }
497 
498 
499  virtual void ComputeTranslation( void );
500 
501  void SetVarTranslation( const OutputVectorType & translation )
502  {
503  this->m_Translation = translation;
504  }
505 
506 
507  virtual void ComputeOffset( void );
508 
509  void SetVarOffset( const OutputVectorType & offset )
510  {
511  this->m_Offset = offset;
512  }
513 
514 
515  void SetVarCenter( const InputPointType & center )
516  {
517  this->m_Center = center;
518  }
519 
520 
524  NonZeroJacobianIndicesType m_NonZeroJacobianIndices;
525  SpatialHessianType m_SpatialHessian;
526  JacobianOfSpatialJacobianType m_JacobianOfSpatialJacobian;
527  JacobianOfSpatialHessianType m_JacobianOfSpatialHessian;
528 
529 private:
530 
531  AdvancedMatrixOffsetTransformBase( const Self & other );
532  const Self & operator=( const Self & );
533 
535  MatrixType m_Matrix; // Matrix of the transformation
536  OutputVectorType m_Offset; // Offset of the transformation
537  mutable InverseMatrixType m_InverseMatrix; // Inverse of the matrix
538  mutable bool m_Singular; // Is m_Inverse singular?
539 
540  InputPointType m_Center;
541  OutputVectorType m_Translation;
542 
546 
549  mutable NonZeroJacobianIndicesType m_NonZeroJacobianIndicesTemp;
550 
551 };
552 
553 } // namespace itk
554 
555 #ifndef ITK_MANUAL_INSTANTIATION
556 #include "itkAdvancedMatrixOffsetTransformBase.hxx"
557 #endif
558 
559 #endif /* __itkAdvancedMatrixOffsetTransformBase_h */
const OutputVectorType & GetTranslation(void) const
void SetVarInverseMatrix(const InverseMatrixType &matrix) const
Matrix< ScalarType, OutputSpaceDimension, InputSpaceDimension > SpatialJacobianType
const Self & operator=(const Self &)
virtual void GetJacobian(const InputPointType &, JacobianType &, NonZeroJacobianIndicesType &) const
std::vector< unsigned long > NonZeroJacobianIndicesType
Superclass::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
virtual void GetJacobianOfSpatialJacobian(const InputPointType &, JacobianOfSpatialJacobianType &, NonZeroJacobianIndicesType &) const
const InverseMatrixType & GetInverseMatrix(void) const
Superclass::ScalarType ScalarType
SpatialJacobianType::InternalMatrixType InternalMatrixType
virtual void GetJacobianOfSpatialHessian(const InputPointType &, JacobianOfSpatialHessianType &, NonZeroJacobianIndicesType &) const
void SetParameters(const ParametersType &parameters)
Superclass::OutputCovariantVectorType OutputCovariantVectorType
Superclass::InputCovariantVectorType InputCovariantVectorType
void PrintSelf(std::ostream &s, Indent indent) const
Superclass::OutputVnlVectorType OutputVnlVectorType
Superclass::OutputCovariantVectorType OutputCovariantVectorType
Superclass::ParametersType ParametersType
Transform maps points, vectors and covariant vectors from an input space to an output space...
void SetVarTranslation(const OutputVectorType &translation)
Superclass::InputVnlVectorType InputVnlVectorType
Superclass::OutputVectorType OutputVectorType
virtual void GetSpatialHessian(const InputPointType &, SpatialHessianType &) const
Superclass::NumberOfParametersType NumberOfParametersType
Superclass::JacobianType JacobianType
Matrix< TScalarType, itkGetStaticConstMacro(InputSpaceDimension), itkGetStaticConstMacro(OutputSpaceDimension) > InverseMatrixType
OutputPointType TransformPoint(const InputPointType &point) const
virtual const ParametersType & GetFixedParameters(void) const
bool GetInverse(Self *inverse) const
virtual TransformCategoryType GetTransformCategory() const
void Compose(const Self *other, bool pre=0)
Superclass::JacobianOfSpatialHessianType JacobianOfSpatialHessianType
Superclass::InputPointType InputPointType
OutputVectorType TransformVector(const InputVectorType &vector) const
itkStaticConstMacro(InputSpaceDimension, unsigned int, NInputDimensions)
Superclass::JacobianOfSpatialJacobianType JacobianOfSpatialJacobianType
Superclass::InputVectorType InputVectorType
const ParametersType & GetParameters(void) const
Matrix< TScalarType, itkGetStaticConstMacro(OutputSpaceDimension), itkGetStaticConstMacro(InputSpaceDimension) > MatrixType
Superclass::OutputPointType OutputPointType
virtual void PrecomputeJacobians(unsigned int paramDims)
void SetTranslation(const OutputVectorType &translation)
std::vector< SpatialJacobianType > JacobianOfSpatialJacobianType
std::vector< SpatialHessianType > JacobianOfSpatialHessianType
virtual void SetFixedParameters(const ParametersType &)
Superclass::InputCovariantVectorType InputCovariantVectorType
FixedArray< Matrix< ScalarType, InputSpaceDimension, InputSpaceDimension >, OutputSpaceDimension > SpatialHessianType
virtual void ComputeMatrixParameters(void)
AdvancedTransform< TScalarType, NInputDimensions, NOutputDimensions > Superclass
virtual void GetSpatialJacobian(const InputPointType &, SpatialJacobianType &) const
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &vector) const
const InverseMatrixType & GetVarInverseMatrix(void) const


Generated on 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo