ITK  5.4.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  * https://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 VDimension = 3>
43 class ITK_TEMPLATE_EXPORT TranslationTransform : public Transform<TParametersValueType, VDimension, VDimension>
44 {
45 public:
46  ITK_DISALLOW_COPY_AND_MOVE(TranslationTransform);
47 
53 
55  itkNewMacro(Self);
56 
58  itkOverrideGetNameOfClassMacro(TranslationTransform);
59 
61  static constexpr unsigned int SpaceDimension = VDimension;
62  static constexpr unsigned int ParametersDimension = VDimension;
63 
65  using typename Superclass::ScalarType;
66 
68  using typename Superclass::FixedParametersType;
69  using typename Superclass::ParametersType;
70 
72  using typename Superclass::JacobianType;
73  using typename Superclass::JacobianPositionType;
74  using typename Superclass::InverseJacobianPositionType;
75 
77  using typename Superclass::NumberOfParametersType;
78 
82 
86 
88  using InputVnlVectorType = vnl_vector_fixed<TParametersValueType, VDimension>;
89  using OutputVnlVectorType = vnl_vector_fixed<TParametersValueType, VDimension>;
90 
94 
97  using InverseTransformBaseType = typename Superclass::InverseTransformBaseType;
99 
101  using 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 & vect) const override;
151 
152  OutputVnlVectorType
153  TransformVector(const InputVnlVectorType & vect) const override;
154 
155  using Superclass::TransformCovariantVector;
156  OutputCovariantVectorType
157  TransformCovariantVector(const InputCovariantVectorType & vect) const override;
158 
162  inline InputPointType
163  BackTransform(const OutputPointType & point) const;
164 
165  inline InputVectorType
166  BackTransform(const OutputVectorType & vect) const;
167 
168  inline InputVnlVectorType
169  BackTransform(const OutputVnlVectorType & vect) const;
170 
171  inline InputCovariantVectorType
172  BackTransform(const OutputCovariantVectorType & vect) 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 & jacobian) 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 VDimension;
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  }
247 protected:
249  ~TranslationTransform() override = default;
251  void
252  PrintSelf(std::ostream & os, Indent indent) const override;
253 
254 private:
255  JacobianType m_IdentityJacobian{};
256  OutputVectorType m_Offset{}; // Offset of the transformation
257 }; // class TranslationTransform
258 
259 // Back transform a point
260 template <typename TParametersValueType, unsigned int VDimension>
261 inline auto
263  -> InputPointType
264 {
265  return point - m_Offset;
266 }
267 
268 // Back transform a vector
269 template <typename TParametersValueType, unsigned int VDimension>
270 inline auto
272  -> InputVectorType
273 {
274  return vect;
275 }
276 
277 // Back transform a vnl_vector
278 template <typename TParametersValueType, unsigned int VDimension>
279 inline auto
282 {
283  return vect;
284 }
285 
286 // Back Transform a CovariantVector
287 template <typename TParametersValueType, unsigned int VDimension>
288 inline auto
291 {
292  return vect;
293 }
294 
295 } // namespace itk
296 
297 #ifndef ITK_MANUAL_INSTANTIATION
298 # include "itkTranslationTransform.hxx"
299 #endif
300 
301 #endif /* itkTranslationTransform_h */
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::OptimizerParameters
Class to hold and manage different parameter types used during optimization.
Definition: itkOptimizerParameters.h:36
itkMatrix.h
itk::TranslationTransform::IsLinear
bool IsLinear() const override
Definition: itkTranslationTransform.h:215
itk::TranslationTransform::OutputVnlVectorType
vnl_vector_fixed< TParametersValueType, VDimension > OutputVnlVectorType
Definition: itkTranslationTransform.h:89
itk::TranslationTransform::BackTransform
InputPointType BackTransform(const OutputPointType &point) const
Definition: itkTranslationTransform.h:262
itk::Vector< TParametersValueType, VDimension >
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::TranslationTransform::InverseTransformBasePointer
typename InverseTransformBaseType::Pointer InverseTransformBasePointer
Definition: itkTranslationTransform.h:98
itk::TranslationTransform::GetOffset
const OutputVectorType & GetOffset() const
Definition: itkTranslationTransform.h:106
itk::TranslationTransform::InverseTransformBaseType
typename Superclass::InverseTransformBaseType InverseTransformBaseType
Definition: itkTranslationTransform.h:97
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itkMacro.h
itk::point
*par Constraints *The filter requires an image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
itk::TranslationTransform
Translation transformation of a vector space (e.g. space coordinates)
Definition: itkTranslationTransform.h:43
itk::TranslationTransform::GetNumberOfParameters
NumberOfParametersType GetNumberOfParameters() const override
Definition: itkTranslationTransform.h:204
itk::TranslationTransform::SetFixedParameters
void SetFixedParameters(const FixedParametersType &) override
Definition: itkTranslationTransform.h:233
itk::TranslationTransform::GetTransformCategory
TransformCategoryEnum GetTransformCategory() const override
Definition: itkTranslationTransform.h:224
itk::TranslationTransform::SetOffset
void SetOffset(const OutputVectorType &offset)
Definition: itkTranslationTransform.h:124
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:70
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Point
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:53
itk::TranslationTransform::InputVnlVectorType
vnl_vector_fixed< TParametersValueType, VDimension > InputVnlVectorType
Definition: itkTranslationTransform.h:88
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:83
AddImageFilter
Definition: itkAddImageFilter.h:81
itkTransform.h
itk::TranslationTransform::GetFixedParameters
const FixedParametersType & GetFixedParameters() const override
Definition: itkTranslationTransform.h:240
itk::Array::SetSize
void SetSize(SizeValueType sz)