ITK  5.2.0
Insight Toolkit
itkTranslationTransform.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 itkTranslationTransform_h
19 #define itkTranslationTransform_h
20 
21 #include "itkTransform.h"
22 #include "itkMacro.h"
23 #include "itkMatrix.h"
24 
25 namespace itk
26 {
27 
42 template <typename TParametersValueType = double, unsigned int NDimensions = 3>
43 class ITK_TEMPLATE_EXPORT TranslationTransform : public Transform<TParametersValueType, NDimensions, NDimensions>
44 {
45 public:
46  ITK_DISALLOW_COPY_AND_ASSIGN(TranslationTransform);
47 
53 
55  itkNewMacro(Self);
56 
58  itkTypeMacro(TranslationTransform, Transform);
59 
61  static constexpr unsigned int SpaceDimension = NDimensions;
62  static constexpr unsigned int ParametersDimension = NDimensions;
63 
65  using ScalarType = typename Superclass::ScalarType;
66 
68  using FixedParametersType = typename Superclass::FixedParametersType;
69  using ParametersType = typename Superclass::ParametersType;
70 
72  using JacobianType = typename Superclass::JacobianType;
73  using JacobianPositionType = typename Superclass::JacobianPositionType;
74  using InverseJacobianPositionType = typename Superclass::InverseJacobianPositionType;
75 
77  using NumberOfParametersType = typename Superclass::NumberOfParametersType;
78 
82 
86 
88  using InputVnlVectorType = vnl_vector_fixed<TParametersValueType, NDimensions>;
89  using OutputVnlVectorType = vnl_vector_fixed<TParametersValueType, NDimensions>;
90 
94 
97  using InverseTransformBaseType = typename Superclass::InverseTransformBaseType;
98  using InverseTransformBasePointer = typename InverseTransformBaseType::Pointer;
99 
101  using TransformCategoryEnum = typename Superclass::TransformCategoryEnum;
102 
105  const OutputVectorType &
106  GetOffset() const
107  {
108  return m_Offset;
109  }
110 
113  void
114  SetParameters(const ParametersType & parameters) override;
115 
117  const ParametersType &
118  GetParameters() const override;
119 
123  void
124  SetOffset(const OutputVectorType & offset)
125  {
126  m_Offset = offset;
127  return;
128  }
129 
131  void
132  Compose(const Self * other, bool pre = false);
133 
138  void
139  Translate(const OutputVectorType & offset, bool pre = false);
140 
145  OutputPointType
146  TransformPoint(const InputPointType & point) const override;
147 
148  using Superclass::TransformVector;
149  OutputVectorType
150  TransformVector(const InputVectorType & vector) const override;
151 
152  OutputVnlVectorType
153  TransformVector(const InputVnlVectorType & vector) const override;
154 
155  using Superclass::TransformCovariantVector;
156  OutputCovariantVectorType
157  TransformCovariantVector(const InputCovariantVectorType & vector) const override;
158 
162  inline InputPointType
163  BackTransform(const OutputPointType & point) const;
164 
165  inline InputVectorType
166  BackTransform(const OutputVectorType & vector) const;
167 
168  inline InputVnlVectorType
169  BackTransform(const OutputVnlVectorType & vector) const;
170 
171  inline InputCovariantVectorType
172  BackTransform(const OutputCovariantVectorType & vector) const;
173 
178  bool
179  GetInverse(Self * inverse) const;
180 
182  InverseTransformBasePointer
183  GetInverseTransform() const override;
184 
186  void
187  ComputeJacobianWithRespectToParameters(const InputPointType & point, JacobianType & j) const override;
188 
189 
194  void
195  ComputeJacobianWithRespectToPosition(const InputPointType & x, JacobianPositionType & jac) const override;
196  using Superclass::ComputeJacobianWithRespectToPosition;
197 
199  void
200  SetIdentity();
201 
203  NumberOfParametersType
204  GetNumberOfParameters() const override
205  {
206  return NDimensions;
207  }
208 
214  bool
215  IsLinear() const override
216  {
217  return true;
218  }
219 
223  TransformCategoryEnum
224  GetTransformCategory() const override
225  {
226  return Self::TransformCategoryEnum::Linear;
227  }
228 
232  void
234  {}
235 
239  const FixedParametersType &
240  GetFixedParameters() const override
241  {
242  this->m_FixedParameters.SetSize(0);
243  return this->m_FixedParameters;
244  }
246 
247 protected:
249  ~TranslationTransform() override = default;
251  void
252  PrintSelf(std::ostream & os, Indent indent) const override;
253 
254 private:
256  OutputVectorType m_Offset; // Offset of the transformation
257 }; // class TranslationTransform
258 
259 // Back transform a point
260 template <typename TParametersValueType, unsigned int NDimensions>
263 {
264  return point - m_Offset;
265 }
266 
267 // Back transform a vector
268 template <typename TParametersValueType, unsigned int NDimensions>
271 {
272  return vect;
273 }
274 
275 // Back transform a vnl_vector
276 template <typename TParametersValueType, unsigned int NDimensions>
279 {
280  return vect;
281 }
282 
283 // Back Transform a CovariantVector
284 template <typename TParametersValueType, unsigned int NDimensions>
287 {
288  return vect;
289 }
290 
291 } // namespace itk
292 
293 #ifndef ITK_MANUAL_INSTANTIATION
294 # include "itkTranslationTransform.hxx"
295 #endif
296 
297 #endif /* itkTranslationTransform_h */
itk::TranslationTransform::GetFixedParameters
const FixedParametersType & GetFixedParameters() const override
Definition: itkTranslationTransform.h:240
itk::TranslationTransform::IsLinear
bool IsLinear() const override
Definition: itkTranslationTransform.h:215
itk::TranslationTransform::JacobianPositionType
typename Superclass::JacobianPositionType JacobianPositionType
Definition: itkTranslationTransform.h:73
itk::OptimizerParameters
Class to hold and manage different parameter types used during optimization.
Definition: itkOptimizerParameters.h:34
itk::TranslationTransform::m_IdentityJacobian
JacobianType m_IdentityJacobian
Definition: itkTranslationTransform.h:255
itk::TranslationTransform::BackTransform
InputPointType BackTransform(const OutputPointType &point) const
Definition: itkTranslationTransform.h:262
itk::TranslationTransform::InputVnlVectorType
vnl_vector_fixed< TParametersValueType, NDimensions > InputVnlVectorType
Definition: itkTranslationTransform.h:88
itk::TranslationTransform::SetFixedParameters
void SetFixedParameters(const FixedParametersType &) override
Definition: itkTranslationTransform.h:233
itkMatrix.h
itk::TranslationTransform::GetNumberOfParameters
NumberOfParametersType GetNumberOfParameters() const override
Definition: itkTranslationTransform.h:204
itk::Vector< TParametersValueType, NDimensions >
itk::TranslationTransform::ScalarType
typename Superclass::ScalarType ScalarType
Definition: itkTranslationTransform.h:65
itk::TranslationTransform::GetTransformCategory
TransformCategoryEnum GetTransformCategory() const override
Definition: itkTranslationTransform.h:224
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::TranslationTransform::OutputVnlVectorType
vnl_vector_fixed< TParametersValueType, NDimensions > OutputVnlVectorType
Definition: itkTranslationTransform.h:89
itk::TranslationTransform::InverseJacobianPositionType
typename Superclass::InverseJacobianPositionType InverseJacobianPositionType
Definition: itkTranslationTransform.h:74
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itkMacro.h
itk::TranslationTransform
Translation transformation of a vector space (e.g. space coordinates)
Definition: itkTranslationTransform.h:43
itk::TransformBaseTemplateEnums::TransformCategory
TransformCategory
Definition: itkTransformBase.h:45
itk::TranslationTransform::InverseTransformBasePointer
typename InverseTransformBaseType::Pointer InverseTransformBasePointer
Definition: itkTranslationTransform.h:98
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:70
itk::TranslationTransform::InverseTransformBaseType
typename Superclass::InverseTransformBaseType InverseTransformBaseType
Definition: itkTranslationTransform.h:97
itk::TranslationTransform::SetOffset
void SetOffset(const OutputVectorType &offset)
Definition: itkTranslationTransform.h:124
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::TranslationTransform::GetOffset
const OutputVectorType & GetOffset() const
Definition: itkTranslationTransform.h:106
itk::Point
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:53
itk::TransformBaseTemplate::NumberOfParametersType
IdentifierType NumberOfParametersType
Definition: itkTransformBase.h:91
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
itkTransform.h
itk::TranslationTransform::m_Offset
OutputVectorType m_Offset
Definition: itkTranslationTransform.h:256
itk::Array::SetSize
void SetSize(SizeValueType sz)
itk::TranslationTransform::JacobianType
typename Superclass::JacobianType JacobianType
Definition: itkTranslationTransform.h:72