ITK  6.0.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
25namespace itk
26{
27
42template <typename TParametersValueType = double, unsigned int VDimension = 3>
43class ITK_TEMPLATE_EXPORT TranslationTransform : public Transform<TParametersValueType, VDimension, VDimension>
44{
45public:
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
69 using typename Superclass::ParametersType;
70
72 using typename Superclass::JacobianType;
75
78
82
86
88 using InputVnlVectorType = vnl_vector_fixed<TParametersValueType, VDimension>;
89 using OutputVnlVectorType = vnl_vector_fixed<TParametersValueType, VDimension>;
90
94
99
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
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
146 TransformPoint(const InputPointType & point) const override;
147
148 using Superclass::TransformVector;
150 TransformVector(const InputVectorType & vect) const override;
151
153 TransformVector(const InputVnlVectorType & vect) const override;
154
155 using Superclass::TransformCovariantVector;
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
172 BackTransform(const OutputCovariantVectorType & vect) const;
173
178 bool
179 GetInverse(Self * inverse) const;
180
183 GetInverseTransform() const override;
184
186 void
188
189
194 void
196 using Superclass::ComputeJacobianWithRespectToPosition;
197
199 void
201
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 }
247protected:
249 ~TranslationTransform() override = default;
251 void
252 PrintSelf(std::ostream & os, Indent indent) const override;
253
254private:
255 JacobianType m_IdentityJacobian{};
256 OutputVectorType m_Offset{}; // Offset of the transformation
257}; // class TranslationTransform
258
259// Back transform a point
260template <typename TParametersValueType, unsigned int VDimension>
261inline auto
264{
265 return point - m_Offset;
266}
267
268// Back transform a vector
269template <typename TParametersValueType, unsigned int VDimension>
270inline auto
273{
274 return vect;
275}
276
277// Back transform a vnl_vector
278template <typename TParametersValueType, unsigned int VDimension>
279inline auto
282{
283 return vect;
284}
285
286// Back Transform a CovariantVector
287template <typename TParametersValueType, unsigned int VDimension>
288inline 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 */
Array2D class representing a 2D array.
Definition: itkArray2D.h:43
void SetSize(SizeValueType sz)
A templated class holding a n-Dimensional covariant vector.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Class to hold and manage different parameter types used during optimization.
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:54
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:84
vnl_matrix_fixed< ParametersValueType, VOutputDimension, VInputDimension > JacobianPositionType
Definition: itkTransform.h:131
vnl_matrix_fixed< ParametersValueType, VInputDimension, VOutputDimension > InverseJacobianPositionType
Definition: itkTransform.h:132
Translation transformation of a vector space (e.g. space coordinates)
OutputVectorType TransformVector(const InputVectorType &vect) const override
const OutputVectorType & GetOffset() const
typename Superclass::InverseTransformBaseType InverseTransformBaseType
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &vect) const override
void ComputeJacobianWithRespectToParameters(const InputPointType &point, JacobianType &jacobian) const override
typename InverseTransformBaseType::Pointer InverseTransformBasePointer
void SetParameters(const ParametersType &parameters) override
~TranslationTransform() override=default
void SetFixedParameters(const FixedParametersType &) override
const ParametersType & GetParameters() const override
OutputPointType TransformPoint(const InputPointType &point) const override
InputPointType BackTransform(const OutputPointType &point) const
bool GetInverse(Self *inverse) const
NumberOfParametersType GetNumberOfParameters() const override
TransformCategoryEnum GetTransformCategory() const override
void PrintSelf(std::ostream &os, Indent indent) const override
const FixedParametersType & GetFixedParameters() const override
vnl_vector_fixed< TParametersValueType, VDimension > InputVnlVectorType
void SetOffset(const OutputVectorType &offset)
void ComputeJacobianWithRespectToPosition(const InputPointType &x, JacobianPositionType &jac) const override
void Compose(const Self *other, bool pre=false)
InverseTransformBasePointer GetInverseTransform() const override
void Translate(const OutputVectorType &offset, bool pre=false)
OutputVnlVectorType TransformVector(const InputVnlVectorType &vect) const override
vnl_vector_fixed< TParametersValueType, VDimension > OutputVnlVectorType
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:63
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
*par Constraints *The filter 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