ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkIdentityTransform.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 itkIdentityTransform_h
19 #define itkIdentityTransform_h
20 
21 #include "itkObject.h"
22 #include "itkPoint.h"
23 #include "itkCovariantVector.h"
24 #include "vnl/vnl_vector_fixed.h"
25 #include "itkArray2D.h"
26 #include "itkTransform.h"
27 
28 namespace itk
29 {
49 template<typename TParametersValueType,
50  unsigned int NDimensions=3>
51 class IdentityTransform : public Transform<TParametersValueType, NDimensions, NDimensions>
52 {
53 public:
59 
61  itkNewMacro(Self);
62 
64  itkTypeMacro(IdentityTransform, Transform);
65 
67  itkStaticConstMacro(InputSpaceDimension, unsigned int, NDimensions);
68  itkStaticConstMacro(OutputSpaceDimension, unsigned int, NDimensions);
70 
77 
78 
81 
84 
86  typedef Vector<TParametersValueType,
87  itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType;
88  typedef Vector<TParametersValueType,
89  itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType;
91 
93  typedef CovariantVector<TParametersValueType,
95  typedef CovariantVector<TParametersValueType,
98 
100  typedef vnl_vector_fixed<TParametersValueType,
101  itkGetStaticConstMacro(InputSpaceDimension)> InputVnlVectorType;
102  typedef vnl_vector_fixed<TParametersValueType,
103  itkGetStaticConstMacro(OutputSpaceDimension)> OutputVnlVectorType;
105 
107  typedef Point<TParametersValueType,
108  itkGetStaticConstMacro(InputSpaceDimension)> InputPointType;
109  typedef Point<TParametersValueType,
110  itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType;
112 
116  typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer;
117 
119  virtual OutputPointType TransformPoint(const InputPointType & point) const ITK_OVERRIDE
120  {
121  return point;
122  }
123 
126  virtual OutputVectorType TransformVector(const InputVectorType & vector) const ITK_OVERRIDE
127  {
128  return vector;
129  }
130 
132  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType & vector) const ITK_OVERRIDE
133  {
134  return vector;
135  }
136 
140  const InputCovariantVectorType & vector) const ITK_OVERRIDE
141  {
142  return vector;
143  }
144 
149  void SetIdentity(void)
150  {
151  }
152 
182  JacobianType & jacobian) const ITK_OVERRIDE
183  {
184  jacobian = this->m_IdentityJacobian;
185  }
186 
192  JacobianType & jac) const ITK_OVERRIDE
193  {
194  jac.SetSize( NDimensions, NDimensions );
195  jac.Fill(0.0);
196  for( unsigned int dim = 0; dim < NDimensions; dim++ )
197  {
198  jac[dim][dim] = 1.0;
199  }
200  }
202 
203  /* Always returns true if not null, as an identity is it's own inverse */
204  bool GetInverse( Self *inverseTransform ) const
205  {
206  return (inverseTransform != ITK_NULLPTR);
207  }
208 
212  {
213  return this->New().GetPointer();
214  }
215 
221  virtual TransformCategoryType GetTransformCategory() const ITK_OVERRIDE
222  {
223  return Self::Linear;
224  }
225 
227  virtual const FixedParametersType & GetFixedParameters() const ITK_OVERRIDE
228  {
229  return this->m_FixedParameters;
230  }
231 
233  virtual void SetFixedParameters(const FixedParametersType &) ITK_OVERRIDE
234  {
235  }
236 
238  virtual const ParametersType & GetParameters() const ITK_OVERRIDE
239  {
240  return this->m_Parameters;
241  }
242 
244  virtual void SetParameters(const ParametersType &) ITK_OVERRIDE
245  {
246  }
247 
248 protected:
249  IdentityTransform() : Transform<TParametersValueType, NDimensions, NDimensions>(0),
250  m_IdentityJacobian(NDimensions, 0)
251  {
252  // The Jacobian is constant, therefore it can be initialized in the
253  // constructor.
254  this->m_IdentityJacobian.Fill(0.0);
255  }
256 
258  {
259  }
260 
261 private:
262  IdentityTransform(const Self &) ITK_DELETE_FUNCTION;
263  void operator=(const Self &) ITK_DELETE_FUNCTION;
264 
266 };
267 } // end namespace itk
268 
269 #endif
CovariantVector< TParametersValueType, itkGetStaticConstMacro(InputSpaceDimension)> InputCovariantVectorType
SmartPointer< Self > Pointer
Light weight base class for most itk classes.
virtual void ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType &jacobian) const override
InverseTransformBaseType::Pointer InverseTransformBasePointer
virtual void ComputeJacobianWithRespectToPosition(const InputPointType &, JacobianType &jac) const override
vnl_vector_fixed< TParametersValueType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVnlVectorType
Superclass::FixedParametersType FixedParametersType
virtual OutputVectorType TransformVector(const InputVectorType &) const
Definition: itkTransform.h:193
ParametersValueType ScalarType
Superclass::TransformCategoryType TransformCategoryType
Implementation of an Identity Transform.
ObjectType * GetPointer() const
virtual OutputPointType TransformPoint(const InputPointType &point) const override
Vector< TParametersValueType, itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType
virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &vector) const override
Superclass::ParametersValueType ParametersValueType
static Pointer New()
Superclass::ParametersType ParametersType
Superclass::InverseTransformBaseType InverseTransformBaseType
Point< TParametersValueType, itkGetStaticConstMacro(InputSpaceDimension)> InputPointType
virtual void SetParameters(const ParametersType &) override
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
Vector< TParametersValueType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType
Superclass::JacobianType JacobianType
vnl_vector_fixed< TParametersValueType, itkGetStaticConstMacro(InputSpaceDimension)> InputVnlVectorType
SmartPointer< const Self > ConstPointer
Superclass::FixedParametersValueType FixedParametersValueType
virtual const ParametersType & GetParameters() const override
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &vector) const override
Superclass::FixedParametersValueType FixedParametersValueType
Definition: itkTransform.h:116
Transform< TParametersValueType, NOutputDimensions, NInputDimensions > InverseTransformBaseType
Definition: itkTransform.h:163
bool GetInverse(Self *inverseTransform) const
Point< TParametersValueType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType
static const unsigned int OutputSpaceDimension
virtual void SetFixedParameters(const FixedParametersType &) override
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
Definition: itkTransform.h:239
CovariantVector< TParametersValueType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputCovariantVectorType
virtual OutputVectorType TransformVector(const InputVectorType &vector) const override
virtual InverseTransformBasePointer GetInverseTransform() const override
static const unsigned int InputSpaceDimension
virtual TransformCategoryType GetTransformCategory() const override
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:52
A templated class holding a n-Dimensional covariant vector.
virtual const FixedParametersType & GetFixedParameters() const override
Transform< TParametersValueType, NDimensions, NDimensions > Superclass