ITK  6.0.0
Insight Toolkit
itkCompositeTransform.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 itkCompositeTransform_h
19#define itkCompositeTransform_h
20
21#include "itkMultiTransform.h"
22
23#include <deque>
24
25namespace itk
26{
27
86template <typename TParametersValueType = double, unsigned int VDimension = 3>
87class ITK_TEMPLATE_EXPORT CompositeTransform : public MultiTransform<TParametersValueType, VDimension, VDimension>
88{
89public:
90 ITK_DISALLOW_COPY_AND_MOVE(CompositeTransform);
91
97
99 itkOverrideGetNameOfClassMacro(CompositeTransform);
100
102 itkNewMacro(Self);
103
107
110
112 using typename Superclass::ScalarType;
113
115 using typename Superclass::FixedParametersType;
117 using typename Superclass::ParametersType;
118 using typename Superclass::ParametersValueType;
119
121 using typename Superclass::DerivativeType;
122
124 using typename Superclass::JacobianType;
127
130
132 using typename Superclass::InputPointType;
133 using typename Superclass::OutputPointType;
134
136 using typename Superclass::InputVectorType;
137 using typename Superclass::OutputVectorType;
138
142
144 using typename Superclass::InputVnlVectorType;
145 using typename Superclass::OutputVnlVectorType;
146
150
154
158
160 using typename Superclass::TransformQueueType;
161
164
166 using TransformsToOptimizeFlagsType = std::deque<bool>;
167
169 static constexpr unsigned int InputDimension = VDimension;
170 static constexpr unsigned int OutputDimension = VDimension;
171
174 virtual void
176 {
177 this->m_TransformsToOptimizeFlags.at(i) = state;
178 this->Modified();
179 }
180
181 virtual void
183 {
184 this->SetNthTransformToOptimize(i, true);
185 }
186
187 virtual void
189 {
190 this->SetNthTransformToOptimize(i, false);
191 }
192
193 virtual void
195 {
196 this->m_TransformsToOptimizeFlags.assign(this->m_TransformsToOptimizeFlags.size(), state);
197 this->Modified();
198 }
199
200 virtual void
202 {
203 this->SetAllTransformsToOptimize(true);
204 }
205
206 virtual void
208 {
209 this->SetAllTransformsToOptimize(false);
210 }
211
212 /* With AddTransform() as the only way to add a transform, we
213 * can have this method to easily allow user to optimize only
214 * the transform added most recently. */
215 virtual void
217 {
218 this->SetAllTransformsToOptimize(false);
219 this->SetNthTransformToOptimizeOn(this->GetNumberOfTransforms() - 1);
220 }
221
222 /* Get whether the Nth transform is set to be optimizied */
223 /* NOTE: ambiguous function name here - are we getting if the Nth transform
224 is set to be optimized, or the Nth of the transforms that are set to be
225 optimized? */
226 virtual bool
228 {
229 return this->m_TransformsToOptimizeFlags.at(i);
230 }
231
233 virtual const TransformsToOptimizeFlagsType &
235 {
236 return this->m_TransformsToOptimizeFlags;
237 }
238
239 void
241 {
242 Superclass::ClearTransformQueue();
243 this->m_TransformsToOptimizeFlags.clear();
244 }
245
251 bool
252 GetInverse(Self * inverse) const;
253
255 GetInverseTransform() const override;
256
272 TransformPoint(const InputPointType & inputPoint) const override;
273
275 using Superclass::TransformVector;
277 TransformVector(const InputVectorType &) const override;
278
280 TransformVector(const InputVnlVectorType & inputVector) const override;
281
283 TransformVector(const InputVectorPixelType & inputVector) const override;
284
286 TransformVector(const InputVectorType & inputVector, const InputPointType & inputPoint) const override;
287
289 TransformVector(const InputVnlVectorType & inputVector, const InputPointType & inputPoint) const override;
290
292 TransformVector(const InputVectorPixelType & inputVector, const InputPointType & inputPoint) const override;
293
295 using Superclass::TransformCovariantVector;
298
301
304 const InputPointType & inputPoint) const override;
305
307 TransformCovariantVector(const InputVectorPixelType & inputVector, const InputPointType & inputPoint) const override;
308
310 using Superclass::TransformDiffusionTensor3D;
312 TransformDiffusionTensor3D(const InputDiffusionTensor3DType & inputTensor) const override;
313
315 TransformDiffusionTensor3D(const InputVectorPixelType & inputTensor) const override;
316
319 const InputPointType & inputPoint) const override;
320
323 const InputPointType & inputPoint) const override;
324
326 using Superclass::TransformSymmetricSecondRankTensor;
329
331 TransformSymmetricSecondRankTensor(const InputVectorPixelType & inputTensor) const override;
332
335 const InputPointType & inputPoint) const override;
336
339 const InputPointType & inputPoint) const override;
340
346 GetTransformCategory() const override;
347
358 const ParametersType &
359 GetParameters() const override;
360
361 /* SetParameters only for transforms that are set to be optimized
362 * See GetParameters() for parameter ordering. */
363 void
364 SetParameters(const ParametersType & inputParameters) override;
365
366 /* GetFixedParameters only for transforms that are set to be optimized
367 * See GetParameters() for parameter ordering. */
368 const FixedParametersType &
369 GetFixedParameters() const override;
370
371 /* SetFixedParameters only for transforms that are set to be optimized.
372 * See GetParameters() for parameter ordering. */
373 void
374 SetFixedParameters(const FixedParametersType & inputParameters) override;
375
376 /* Get total number of parameters for transforms that are set to be
377 * optimized */
379 GetNumberOfParameters() const override;
380
381 /* Get total number of local parameters for transforms that are set
382 * to be optimized */
385
386 /* Get total number of fixed parameters for transforms that are set
387 * to be optimized */
390
393 void
394 UpdateTransformParameters(const DerivativeType & update, ScalarType factor = 1.0) override;
395
399 virtual void
401
406 void
408
417 void
419 JacobianType & outJacobian,
420 JacobianType & cacheJacobian) const override;
423protected:
425 ~CompositeTransform() override = default;
426 void
427 PrintSelf(std::ostream & os, Indent indent) const override;
428
430 typename LightObject::Pointer
431 InternalClone() const override;
432
433 void
435 {
436 Superclass::PushFrontTransform(t);
437 /* Add element to list of flags, and set true by default */
438 this->m_TransformsToOptimizeFlags.push_front(true);
439 }
440
441 void
443 {
444 Superclass::PushBackTransform(t);
445 /* Add element to list of flags, and set true by default */
446 this->m_TransformsToOptimizeFlags.push_back(true);
447 }
448
449 void
451 {
452 Superclass::PopFrontTransform();
453 this->m_TransformsToOptimizeFlags.pop_front();
454 }
455
456 void
458 {
459 Superclass::PopBackTransform();
460 this->m_TransformsToOptimizeFlags.pop_back();
461 }
462
464 const TransformQueueType &
466
467 mutable TransformQueueType m_TransformsToOptimizeQueue{};
468 TransformsToOptimizeFlagsType m_TransformsToOptimizeFlags{};
469
470private:
471 mutable ModifiedTimeType m_PreviousTransformsToOptimizeUpdateTime{};
472};
473
474} // end namespace itk
475
476#ifndef ITK_MANUAL_INSTANTIATION
477# include "itkCompositeTransform.hxx"
478#endif
479
480#endif // itkCompositeTransform_h
Array2D class representing a 2D array.
Definition: itkArray2D.h:43
Array class with size defined at construction time.
Definition: itkArray.h:48
This class contains a list of transforms and concatenates them by composition.
typename TransformType::Pointer TransformTypePointer
OutputVectorPixelType TransformCovariantVector(const InputVectorPixelType &inputVector, const InputPointType &inputPoint) const override
void PrintSelf(std::ostream &os, Indent indent) const override
ParametersValueType ScalarType
OutputDiffusionTensor3DType TransformDiffusionTensor3D(const InputDiffusionTensor3DType &inputTensor) const override
OutputVectorPixelType TransformDiffusionTensor3D(const InputVectorPixelType &inputTensor) const override
TransformCategoryEnum GetTransformCategory() const override
OutputVectorType TransformVector(const InputVectorType &inputVector, const InputPointType &inputPoint) const override
std::deque< TransformTypePointer > TransformQueueType
OutputVectorPixelType TransformCovariantVector(const InputVectorPixelType &) const override
OutputVectorPixelType TransformVector(const InputVectorPixelType &inputVector, const InputPointType &inputPoint) const override
OutputVnlVectorType TransformVector(const InputVnlVectorType &inputVector, const InputPointType &inputPoint) const override
typename Superclass::TransformType TransformType
virtual void SetNthTransformToOptimizeOff(SizeValueType i)
void PushBackTransform(TransformTypePointer t) override
OutputSymmetricSecondRankTensorType TransformSymmetricSecondRankTensor(const InputSymmetricSecondRankTensorType &inputTensor, const InputPointType &inputPoint) const override
virtual void SetAllTransformsToOptimizeOff()
std::deque< bool > TransformsToOptimizeFlagsType
virtual void SetNthTransformToOptimizeOn(SizeValueType i)
void ComputeJacobianWithRespectToParametersCachedTemporaries(const InputPointType &p, JacobianType &outJacobian, JacobianType &cacheJacobian) const override
OutputDiffusionTensor3DType TransformDiffusionTensor3D(const InputDiffusionTensor3DType &inputTensor, const InputPointType &inputPoint) const override
OutputPointType TransformPoint(const InputPointType &inputPoint) const override
void UpdateTransformParameters(const DerivativeType &update, ScalarType factor=1.0) override
OutputVectorPixelType TransformDiffusionTensor3D(const InputVectorPixelType &inputTensor, const InputPointType &inputPoint) const override
NumberOfParametersType GetNumberOfLocalParameters() const override
OutputVnlVectorType TransformVector(const InputVnlVectorType &inputVector) const override
OutputSymmetricSecondRankTensorType TransformSymmetricSecondRankTensor(const InputSymmetricSecondRankTensorType &inputTensor) const override
virtual void SetNthTransformToOptimize(SizeValueType i, bool state)
void ComputeJacobianWithRespectToParameters(const InputPointType &p, JacobianType &outJacobian) const override
const ParametersType & GetParameters() const override
void SetFixedParameters(const FixedParametersType &inputParameters) override
OutputVectorPixelType TransformSymmetricSecondRankTensor(const InputVectorPixelType &inputTensor) const override
virtual const TransformsToOptimizeFlagsType & GetTransformsToOptimizeFlags() const
LightObject::Pointer InternalClone() const override
OutputVectorPixelType TransformVector(const InputVectorPixelType &inputVector) const override
const TransformQueueType & GetTransformsToOptimizeQueue() const
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &inputVector, const InputPointType &inputPoint) const override
InverseTransformBasePointer GetInverseTransform() const override
void SetParameters(const ParametersType &inputParameters) override
virtual void FlattenTransformQueue()
virtual void SetAllTransformsToOptimize(bool state)
virtual void SetOnlyMostRecentTransformToOptimizeOn()
NumberOfParametersType GetNumberOfFixedParameters() const override
~CompositeTransform() override=default
const FixedParametersType & GetFixedParameters() const override
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const override
virtual void SetAllTransformsToOptimizeOn()
OutputVectorPixelType TransformSymmetricSecondRankTensor(const InputVectorPixelType &inputTensor, const InputPointType &inputPoint) const override
bool GetInverse(Self *inverse) const
NumberOfParametersType GetNumberOfParameters() const override
void PushFrontTransform(TransformTypePointer t) override
OutputVectorType TransformVector(const InputVectorType &) const override
virtual bool GetNthTransformToOptimize(SizeValueType i) const
A templated class holding a n-Dimensional covariant vector.
Represent a diffusion tensor as used in DTI images.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
This abstract class contains a list of transforms and provides basic methods.
typename TransformType::Pointer TransformTypePointer
ParametersValueType ScalarType
std::deque< TransformTypePointer > TransformQueueType
vnl_vector_fixed< TParametersValueType, VInputDimension > InputVnlVectorType
Definition: itkTransform.h:156
vnl_matrix_fixed< ParametersValueType, VOutputDimension, VInputDimension > JacobianPositionType
Definition: itkTransform.h:131
vnl_matrix_fixed< ParametersValueType, VInputDimension, VOutputDimension > InverseJacobianPositionType
Definition: itkTransform.h:132
typename InverseTransformBaseType::Pointer InverseTransformBasePointer
Definition: itkTransform.h:167
vnl_vector_fixed< TParametersValueType, VOutputDimension > OutputVnlVectorType
Definition: itkTransform.h:157
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
Represent a symmetric tensor of second rank.
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:84
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:63
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:105
unsigned long SizeValueType
Definition: itkIntTypes.h:86