ITK  5.2.0
Insight Toolkit
itkIdentityTransform.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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, unsigned int NDimensions = 3>
50 class ITK_TEMPLATE_EXPORT IdentityTransform : public Transform<TParametersValueType, NDimensions, NDimensions>
51 {
52 public:
53  ITK_DISALLOW_COPY_AND_MOVE(IdentityTransform);
54 
60 
62  itkNewMacro(Self);
63 
65  itkTypeMacro(IdentityTransform, Transform);
66 
68  static constexpr unsigned int InputSpaceDimension = NDimensions;
69  static constexpr unsigned int OutputSpaceDimension = NDimensions;
70 
72  using ParametersType = typename Superclass::ParametersType;
73  using ParametersValueType = typename Superclass::ParametersValueType;
74  using FixedParametersType = typename Superclass::FixedParametersType;
75  using FixedParametersValueType = typename Superclass::FixedParametersValueType;
77 
78 
80  using JacobianType = typename Superclass::JacobianType;
81  using JacobianPositionType = typename Superclass::JacobianPositionType;
82  using InverseJacobianPositionType = typename Superclass::InverseJacobianPositionType;
83 
85  using TransformCategoryEnum = typename Superclass::TransformCategoryEnum;
86 
90 
94 
96  using InputVnlVectorType = vnl_vector_fixed<TParametersValueType, Self::InputSpaceDimension>;
97  using OutputVnlVectorType = vnl_vector_fixed<TParametersValueType, Self::OutputSpaceDimension>;
98 
102 
105  using InverseTransformBaseType = typename Superclass::InverseTransformBaseType;
106  using InverseTransformBasePointer = typename InverseTransformBaseType::Pointer;
107 
110  TransformPoint(const InputPointType & point) const override
111  {
112  return point;
113  }
114 
116  using Superclass::TransformVector;
117  OutputVectorType
118  TransformVector(const InputVectorType & vector) const override
119  {
120  return vector;
121  }
122 
124  OutputVnlVectorType
125  TransformVector(const InputVnlVectorType & vector) const override
126  {
127  return vector;
128  }
129 
131  using Superclass::TransformCovariantVector;
132  OutputCovariantVectorType
133  TransformCovariantVector(const InputCovariantVectorType & vector) const override
134  {
135  return vector;
136  }
137 
142  void
144  {}
145 
174  void
176  {
177  jacobian = this->m_ZeroJacobian;
178  }
179 
180 
185  void
187  {
188  jac.set_identity();
189  }
190  using Superclass::ComputeJacobianWithRespectToPosition;
192 
193  /* Always returns true if not null, as an identity is it's own inverse */
194  bool
195  GetInverse(Self * inverseTransform) const
196  {
197  return (inverseTransform != nullptr);
198  }
199 
202  InverseTransformBasePointer
203  GetInverseTransform() const override
204  {
205  return this->New().GetPointer();
206  }
207 
213  TransformCategoryEnum
214  GetTransformCategory() const override
215  {
216  return Self::TransformCategoryEnum::Linear;
217  }
218 
220  const FixedParametersType &
221  GetFixedParameters() const override
222  {
223  return this->m_FixedParameters;
224  }
225 
227  void
229  {}
230 
232  const ParametersType &
233  GetParameters() const override
234  {
235  return this->m_Parameters;
236  }
237 
239  void
240  SetParameters(const ParametersType &) override
241  {}
242 
243 protected:
245  : 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
itk::IdentityTransform::JacobianPositionType
typename Superclass::JacobianPositionType JacobianPositionType
Definition: itkIdentityTransform.h:81
itk::IdentityTransform::InverseTransformBaseType
typename Superclass::InverseTransformBaseType InverseTransformBaseType
Definition: itkIdentityTransform.h:105
itk::IdentityTransform::m_ZeroJacobian
JacobianType m_ZeroJacobian
Definition: itkIdentityTransform.h:256
itk::IdentityTransform::ComputeJacobianWithRespectToParameters
void ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType &jacobian) const override
Definition: itkIdentityTransform.h:175
itk::IdentityTransform
Implementation of an Identity Transform.
Definition: itkIdentityTransform.h:50
itkCovariantVector.h
itk::IdentityTransform::FixedParametersValueType
typename Superclass::FixedParametersValueType FixedParametersValueType
Definition: itkIdentityTransform.h:75
itk::IdentityTransform::JacobianType
typename Superclass::JacobianType JacobianType
Definition: itkIdentityTransform.h:80
itkPoint.h
itk::IdentityTransform::ScalarType
ParametersValueType ScalarType
Definition: itkIdentityTransform.h:76
itk::IdentityTransform::ComputeJacobianWithRespectToPosition
void ComputeJacobianWithRespectToPosition(const InputPointType &, JacobianPositionType &jac) const override
Definition: itkIdentityTransform.h:186
itk::IdentityTransform::ParametersType
typename Superclass::ParametersType ParametersType
Definition: itkIdentityTransform.h:72
itk::Vector< TParametersValueType, Self::InputSpaceDimension >
itk::IdentityTransform::SetIdentity
void SetIdentity()
Definition: itkIdentityTransform.h:143
itk::SmartPointer< Self >
itk::IdentityTransform::FixedParametersType
typename Superclass::FixedParametersType FixedParametersType
Definition: itkIdentityTransform.h:74
itk::IdentityTransform::TransformPoint
OutputPointType TransformPoint(const InputPointType &point) const override
Definition: itkIdentityTransform.h:110
itk::IdentityTransform::OutputVnlVectorType
vnl_vector_fixed< TParametersValueType, Self::OutputSpaceDimension > OutputVnlVectorType
Definition: itkIdentityTransform.h:97
itk::IdentityTransform::InverseTransformBasePointer
typename InverseTransformBaseType::Pointer InverseTransformBasePointer
Definition: itkIdentityTransform.h:106
itk::IdentityTransform::GetInverseTransform
InverseTransformBasePointer GetInverseTransform() const override
Definition: itkIdentityTransform.h:203
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::IdentityTransform::SetFixedParameters
void SetFixedParameters(const FixedParametersType &) override
Definition: itkIdentityTransform.h:228
itk::IdentityTransform::TransformVector
OutputVectorType TransformVector(const InputVectorType &vector) const override
Definition: itkIdentityTransform.h:118
itk::IdentityTransform::SetParameters
void SetParameters(const ParametersType &) override
Definition: itkIdentityTransform.h:240
itk::IdentityTransform::GetInverse
bool GetInverse(Self *inverseTransform) const
Definition: itkIdentityTransform.h:195
itk::IdentityTransform::GetFixedParameters
const FixedParametersType & GetFixedParameters() const override
Definition: itkIdentityTransform.h:221
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:70
itkObject.h
itkArray2D.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::IdentityTransform::IdentityTransform
IdentityTransform()
Definition: itkIdentityTransform.h:244
itk::IdentityTransform::TransformCategoryEnum
typename Superclass::TransformCategoryEnum TransformCategoryEnum
Definition: itkIdentityTransform.h:85
itk::Point< TParametersValueType, Self::InputSpaceDimension >
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
itk::IdentityTransform::TransformVector
OutputVnlVectorType TransformVector(const InputVnlVectorType &vector) const override
Definition: itkIdentityTransform.h:125
itk::IdentityTransform::TransformCovariantVector
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &vector) const override
Definition: itkIdentityTransform.h:133
itkTransform.h
itk::IdentityTransform::GetParameters
const ParametersType & GetParameters() const override
Definition: itkIdentityTransform.h:233
itk::IdentityTransform::InverseJacobianPositionType
typename Superclass::InverseJacobianPositionType InverseJacobianPositionType
Definition: itkIdentityTransform.h:82
itk::IdentityTransform::InputVnlVectorType
vnl_vector_fixed< TParametersValueType, Self::InputSpaceDimension > InputVnlVectorType
Definition: itkIdentityTransform.h:96
itk::IdentityTransform::ParametersValueType
typename Superclass::ParametersValueType ParametersValueType
Definition: itkIdentityTransform.h:73
itk::IdentityTransform::GetTransformCategory
TransformCategoryEnum GetTransformCategory() const override
Definition: itkIdentityTransform.h:214