ITK  5.0.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 ITK_TEMPLATE_EXPORT IdentityTransform : public Transform<TParametersValueType, NDimensions, NDimensions>
52 {
53 public:
54  ITK_DISALLOW_COPY_AND_ASSIGN(IdentityTransform);
55 
61 
63  itkNewMacro(Self);
64 
66  itkTypeMacro(IdentityTransform, Transform);
67 
69  static constexpr unsigned int InputSpaceDimension = NDimensions;
70  static constexpr unsigned int OutputSpaceDimension = NDimensions;
71 
73  using ParametersType = typename Superclass::ParametersType;
74  using ParametersValueType = typename Superclass::ParametersValueType;
75  using FixedParametersType = typename Superclass::FixedParametersType;
76  using FixedParametersValueType = typename Superclass::FixedParametersValueType;
78 
79 
81  using JacobianType = typename Superclass::JacobianType;
82  using JacobianPositionType = typename Superclass::JacobianPositionType;
83  using InverseJacobianPositionType = typename Superclass::InverseJacobianPositionType;
84 
86  using TransformCategoryType = typename Superclass::TransformCategoryType;
87 
89  using InputVectorType = Vector<TParametersValueType,
90  Self::InputSpaceDimension>;
91  using OutputVectorType = Vector<TParametersValueType,
92  Self::OutputSpaceDimension>;
93 
95  using InputCovariantVectorType = CovariantVector<TParametersValueType,
96  Self::InputSpaceDimension>;
97  using OutputCovariantVectorType = CovariantVector<TParametersValueType,
98  Self::OutputSpaceDimension>;
99 
101  using InputVnlVectorType = vnl_vector_fixed<TParametersValueType,
102  Self::InputSpaceDimension>;
103  using OutputVnlVectorType = vnl_vector_fixed<TParametersValueType,
104  Self::OutputSpaceDimension>;
105 
107  using InputPointType = Point<TParametersValueType,
108  Self::InputSpaceDimension>;
109  using OutputPointType = Point<TParametersValueType,
110  Self::OutputSpaceDimension>;
111 
114  using InverseTransformBaseType = typename Superclass::InverseTransformBaseType;
115  using InverseTransformBasePointer = typename InverseTransformBaseType::Pointer;
116 
118  OutputPointType TransformPoint(const InputPointType & point) const override
119  {
120  return point;
121  }
122 
124  using Superclass::TransformVector;
125  OutputVectorType TransformVector(const InputVectorType & vector) const override
126  {
127  return vector;
128  }
129 
132  {
133  return vector;
134  }
135 
137  using Superclass::TransformCovariantVector;
139  const InputCovariantVectorType & vector) const override
140  {
141  return vector;
142  }
143 
148  void SetIdentity()
149  {
150  }
151 
181  JacobianType & jacobian) const override
182  {
183  jacobian = this->m_ZeroJacobian;
184  }
185 
186 
192  JacobianPositionType & jac) const override
193  {
194  jac.set_identity();
195  }
196  using Superclass::ComputeJacobianWithRespectToPosition;
198 
199  /* Always returns true if not null, as an identity is it's own inverse */
200  bool GetInverse( Self *inverseTransform ) const
201  {
202  return (inverseTransform != nullptr);
203  }
204 
208  {
209  return this->New().GetPointer();
210  }
211 
218  {
219  return Self::Linear;
220  }
221 
223  const FixedParametersType & GetFixedParameters() const override
224  {
225  return this->m_FixedParameters;
226  }
227 
230  {
231  }
232 
234  const ParametersType & GetParameters() const override
235  {
236  return this->m_Parameters;
237  }
238 
240  void SetParameters(const ParametersType &) override
241  {
242  }
243 
244 protected:
245  IdentityTransform() : Transform<TParametersValueType, NDimensions, NDimensions>(0),
246  m_ZeroJacobian(NDimensions, 0)
247  {
248  // The Jacobian is constant, therefore it can be initialized in the
249  // constructor.
250  this->m_ZeroJacobian.Fill(0.0);
251  }
252 
253  ~IdentityTransform() override = default;
254 
255 private:
257 };
258 } // end namespace itk
259 
260 #endif
Light weight base class for most itk classes.
void ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType &jacobian) const override
typename Superclass::FixedParametersType FixedParametersType
typename InverseTransformBaseType::Pointer InverseTransformBasePointer
typename Superclass::FixedParametersValueType FixedParametersValueType
Implementation of an Identity Transform.
InverseTransformBasePointer GetInverseTransform() const override
void ComputeJacobianWithRespectToPosition(const InputPointType &, JacobianPositionType &jac) const override
typename Superclass::ParametersValueType ParametersValueType
vnl_vector_fixed< TParametersValueType, Self::InputSpaceDimension > InputVnlVectorType
void SetParameters(const ParametersType &) override
typename Superclass::JacobianType JacobianType
const FixedParametersType & GetFixedParameters() const override
typename Superclass::InverseJacobianPositionType InverseJacobianPositionType
OutputVectorType TransformVector(const InputVectorType &vector) const override
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:83
TransformCategoryType GetTransformCategory() const override
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &vector) const override
ParametersValueType ScalarType
typename Superclass::InverseTransformBaseType InverseTransformBaseType
OutputPointType TransformPoint(const InputPointType &point) const override
void SetFixedParameters(const FixedParametersType &) override
typename Superclass::JacobianPositionType JacobianPositionType
typename Superclass::ParametersType ParametersType
bool GetInverse(Self *inverseTransform) const
OutputVnlVectorType TransformVector(const InputVnlVectorType &vector) const override
A templated class holding a n-Dimensional covariant vector.
const ParametersType & GetParameters() const override
vnl_vector_fixed< TParametersValueType, Self::OutputSpaceDimension > OutputVnlVectorType