go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkAdvancedTransform.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
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/*=========================================================================
19
20 Program: Insight Segmentation & Registration Toolkit
21 Module: $RCSfile: itkTransform.h,v $
22 Date: $Date: 2008-06-29 12:58:58 $
23 Version: $Revision: 1.64 $
24
25 Copyright (c) Insight Software Consortium. All rights reserved.
26 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
27
28 This software is distributed WITHOUT ANY WARRANTY; without even
29 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
30 PURPOSE. See the above copyright notices for more information.
31
32=========================================================================*/
33#ifndef itkAdvancedTransform_h
34#define itkAdvancedTransform_h
35
36#include "itkTransform.h"
37#include "itkMatrix.h"
38#include "itkFixedArray.h"
39#include <cassert>
40
41namespace itk
42{
43
82template <class TScalarType, unsigned int NInputDimensions = 3, unsigned int NOutputDimensions = 3>
83class ITK_TEMPLATE_EXPORT AdvancedTransform : public Transform<TScalarType, NInputDimensions, NOutputDimensions>
84{
85public:
87
90 using Superclass = Transform<TScalarType, NInputDimensions, NOutputDimensions>;
91 using Pointer = SmartPointer<Self>;
92 using ConstPointer = SmartPointer<const Self>;
93
95 // itkNewMacro( Self );
96
98 itkTypeMacro(AdvancedTransform, Transform);
99
101 itkStaticConstMacro(InputSpaceDimension, unsigned int, NInputDimensions);
102 itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions);
103
105 using typename Superclass::ScalarType;
106 using typename Superclass::ParametersType;
107 using typename Superclass::FixedParametersType;
108 using typename Superclass::ParametersValueType;
109 using typename Superclass::NumberOfParametersType;
110 using typename Superclass::DerivativeType;
111 using typename Superclass::JacobianType;
112 using typename Superclass::InputVectorType;
113 using typename Superclass::OutputVectorType;
114 using typename Superclass::InputCovariantVectorType;
115 using typename Superclass::OutputCovariantVectorType;
116 using typename Superclass::InputVnlVectorType;
117 using typename Superclass::OutputVnlVectorType;
118 using typename Superclass::InputPointType;
119 using typename Superclass::OutputPointType;
120
121 using InverseTransformBaseType = typename Superclass::InverseTransformBaseType;
122 using typename Superclass::InverseTransformBasePointer;
123
125 using TransformType = Transform<TScalarType, NInputDimensions, NOutputDimensions>;
126 using TransformTypePointer = typename TransformType::Pointer;
127 using TransformTypeConstPointer = typename TransformType::ConstPointer;
128
133 using NonZeroJacobianIndicesType = std::vector<unsigned long>;
134 using SpatialJacobianType = Matrix<ScalarType, OutputSpaceDimension, InputSpaceDimension>;
135 using JacobianOfSpatialJacobianType = std::vector<SpatialJacobianType>;
136 // \todo: think about the SpatialHessian type, should be a 3D native type
138 FixedArray<Matrix<ScalarType, InputSpaceDimension, InputSpaceDimension>, OutputSpaceDimension>;
139 using JacobianOfSpatialHessianType = std::vector<SpatialHessianType>;
140 using InternalMatrixType = typename SpatialJacobianType::InternalMatrixType;
141
147 using MovingImageGradientType = OutputCovariantVectorType;
148 using MovingImageGradientValueType = typename MovingImageGradientType::ValueType;
149
151 virtual NumberOfParametersType
153
155 itkGetConstMacro(HasNonZeroSpatialHessian, bool);
156 itkGetConstMacro(HasNonZeroJacobianOfSpatialHessian, bool);
157
184 virtual void
185 GetJacobian(const InputPointType & inputPoint,
186 JacobianType & j,
187 NonZeroJacobianIndicesType & nonZeroJacobianIndices) const = 0;
188
192 virtual void
193 EvaluateJacobianWithImageGradientProduct(const InputPointType & inputPoint,
194 const MovingImageGradientType & movingImageGradient,
195 DerivativeType & imageJacobian,
196 NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
197
224 virtual void
225 GetSpatialJacobian(const InputPointType & inputPoint, SpatialJacobianType & sj) const = 0;
226
228 void
229 ComputeJacobianWithRespectToParameters(const InputPointType & itkNotUsed(p),
230 JacobianType & itkNotUsed(j)) const override
231 {
232 itkExceptionMacro("This ITK4 function is currently not used in elastix.");
233 }
234
235
252 virtual void
253 GetSpatialHessian(const InputPointType & inputPoint, SpatialHessianType & sh) const = 0;
254
261 virtual void
262 GetJacobianOfSpatialJacobian(const InputPointType & inputPoint,
264 NonZeroJacobianIndicesType & nonZeroJacobianIndices) const = 0;
265
269 virtual void
270 GetJacobianOfSpatialJacobian(const InputPointType & inputPoint,
273 NonZeroJacobianIndicesType & nonZeroJacobianIndices) const = 0;
274
281 virtual void
282 GetJacobianOfSpatialHessian(const InputPointType & inputPoint,
284 NonZeroJacobianIndicesType & nonZeroJacobianIndices) const = 0;
285
289 virtual void
290 GetJacobianOfSpatialHessian(const InputPointType & inputPoint,
293 NonZeroJacobianIndicesType & nonZeroJacobianIndices) const = 0;
294
295protected:
296 AdvancedTransform() = default;
297
298 // Inherit the other (non-default) constructor from itk::Transform.
299 using Superclass::Superclass;
300
301 ~AdvancedTransform() override = default;
302
303 bool m_HasNonZeroSpatialHessian{ true };
304 bool m_HasNonZeroJacobianOfSpatialHessian{ true };
305};
306
307namespace ImplementationDetails
308{
310template <class TScalarType, unsigned int VInputVectorSize>
311void
312EvaluateInnerProduct(const vnl_matrix<TScalarType> & inputMatrix,
313 const CovariantVector<TScalarType, VInputVectorSize> & inputVector,
314 vnl_vector<TScalarType> & outputVector)
315{
316 assert(inputMatrix.rows() == inputVector.size());
317 assert(inputMatrix.columns() == outputVector.size());
318
319 auto inputMatrixIterator = inputMatrix.begin();
320
321 outputVector.fill(0.0);
322
323 for (const double inputVectorElement : inputVector)
324 {
325 for (auto & outputVectorElement : outputVector)
326 {
327 outputVectorElement += (*inputMatrixIterator) * inputVectorElement;
328 ++inputMatrixIterator;
329 }
330 }
331}
332} // namespace ImplementationDetails
333
334} // end namespace itk
335
336#ifndef ITK_MANUAL_INSTANTIATION
337# include "itkAdvancedTransform.hxx"
338#endif
339
340#endif
Transform maps points, vectors and covariant vectors from an input space to an output space.
typename SpatialJacobianType::InternalMatrixType InternalMatrixType
ITK_DISALLOW_COPY_AND_MOVE(AdvancedTransform)
virtual void EvaluateJacobianWithImageGradientProduct(const InputPointType &inputPoint, const MovingImageGradientType &movingImageGradient, DerivativeType &imageJacobian, NonZeroJacobianIndicesType &nonZeroJacobianIndices) const
typename Superclass::InverseTransformBaseType InverseTransformBaseType
FixedArray< Matrix< ScalarType, InputSpaceDimension, InputSpaceDimension >, OutputSpaceDimension > SpatialHessianType
virtual void GetSpatialHessian(const InputPointType &inputPoint, SpatialHessianType &sh) const =0
virtual void GetJacobian(const InputPointType &inputPoint, JacobianType &j, NonZeroJacobianIndicesType &nonZeroJacobianIndices) const =0
Matrix< ScalarType, OutputSpaceDimension, InputSpaceDimension > SpatialJacobianType
itkStaticConstMacro(InputSpaceDimension, unsigned int, NInputDimensions)
virtual void GetJacobianOfSpatialHessian(const InputPointType &inputPoint, JacobianOfSpatialHessianType &jsh, NonZeroJacobianIndicesType &nonZeroJacobianIndices) const =0
Transform< TScalarType, NInputDimensions, NOutputDimensions > Superclass
void ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType &) const override
virtual NumberOfParametersType GetNumberOfNonZeroJacobianIndices() const
SmartPointer< const Self > ConstPointer
std::vector< SpatialHessianType > JacobianOfSpatialHessianType
typename TransformType::Pointer TransformTypePointer
virtual void GetJacobianOfSpatialJacobian(const InputPointType &inputPoint, SpatialJacobianType &sj, JacobianOfSpatialJacobianType &jsj, NonZeroJacobianIndicesType &nonZeroJacobianIndices) const =0
std::vector< SpatialJacobianType > JacobianOfSpatialJacobianType
typename TransformType::ConstPointer TransformTypeConstPointer
virtual void GetSpatialJacobian(const InputPointType &inputPoint, SpatialJacobianType &sj) const =0
~AdvancedTransform() override=default
itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions)
virtual void GetJacobianOfSpatialHessian(const InputPointType &inputPoint, SpatialHessianType &sh, JacobianOfSpatialHessianType &jsh, NonZeroJacobianIndicesType &nonZeroJacobianIndices) const =0
typename MovingImageGradientType::ValueType MovingImageGradientValueType
virtual void GetJacobianOfSpatialJacobian(const InputPointType &inputPoint, JacobianOfSpatialJacobianType &jsj, NonZeroJacobianIndicesType &nonZeroJacobianIndices) const =0
std::vector< unsigned long > NonZeroJacobianIndicesType
Transform< TScalarType, NInputDimensions, NOutputDimensions > TransformType
OutputCovariantVectorType MovingImageGradientType
void EvaluateInnerProduct(const vnl_matrix< TScalarType > &inputMatrix, const CovariantVector< TScalarType, VInputVectorSize > &inputVector, vnl_vector< TScalarType > &outputVector)


Generated on 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo