go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkAdvancedBSplineDeformableTransformBase.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#ifndef itkAdvancedBSplineDeformableTransformBase_h
19#define itkAdvancedBSplineDeformableTransformBase_h
20
22#include "itkImage.h"
23#include "itkImageRegion.h"
24
25namespace itk
26{
27
38template <class TScalarType = double, // Data type for scalars
39 unsigned int NDimensions = 3>
40// Number of dimensions
42 : public AdvancedTransform<TScalarType, NDimensions, NDimensions>
43{
44public:
46
50 using Pointer = SmartPointer<Self>;
51 using ConstPointer = SmartPointer<const Self>;
52
55
57 itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
58
60 static constexpr unsigned int NumberOfFixedParameters = NDimensions * (NDimensions + 3);
61
63 using typename Superclass::ParametersType;
64 using typename Superclass::FixedParametersType;
65 using typename Superclass::ParametersValueType;
66 using typename Superclass::NumberOfParametersType;
67 using typename Superclass::DerivativeType;
68 using typename Superclass::JacobianType;
69 using typename Superclass::ScalarType;
70 using typename Superclass::InputPointType;
71 using typename Superclass::OutputPointType;
72 using typename Superclass::InputVectorType;
73 using typename Superclass::OutputVectorType;
74 using typename Superclass::InputVnlVectorType;
75 using typename Superclass::OutputVnlVectorType;
76 using typename Superclass::InputCovariantVectorType;
77 using typename Superclass::OutputCovariantVectorType;
78 using typename Superclass::TransformCategoryEnum;
79
83 using typename Superclass::SpatialHessianType;
85 using typename Superclass::InternalMatrixType;
88
89 /* Creates a `BSplineDeformableTransform` of the specified derived type and spline order. */
90 template <template <class, unsigned, unsigned> class TBSplineDeformableTransform>
91 static Pointer
92 Create(const unsigned splineOrder)
93 {
94 switch (splineOrder)
95 {
96 case 1:
97 {
98 return TBSplineDeformableTransform<TScalarType, NDimensions, 1>::New();
99 }
100 case 2:
101 {
102 return TBSplineDeformableTransform<TScalarType, NDimensions, 2>::New();
103 }
104 case 3:
105 {
106 return TBSplineDeformableTransform<TScalarType, NDimensions, 3>::New();
107 }
108 }
109 itkGenericExceptionMacro(<< "ERROR: The provided spline order (" << splineOrder << ") is not supported.");
110 }
111
112
113 unsigned
115 {
116 return m_SplineOrder;
117 }
118
119
138 void
139 SetParameters(const ParametersType & parameters) override;
140
156 void
157 SetFixedParameters(const FixedParametersType & parameters) override;
158
175 void
176 SetParametersByValue(const ParametersType & parameters) override;
177
186 void
187 SetIdentity();
188
190 const ParametersType &
191 GetParameters() const override;
194 const FixedParametersType &
195 GetFixedParameters() const override;
196
198 using PixelType = typename ParametersType::ValueType;
200 using ImagePointer = typename ImageType::Pointer;
201
203 virtual const ImagePointer *
205 {
206 return this->m_CoefficientImages;
207 }
208
220 virtual void
222
224 using RegionType = ImageRegion<Self::SpaceDimension>;
225
226 using IndexType = typename RegionType::IndexType;
227 using SizeType = typename RegionType::SizeType;
228 using SpacingType = typename ImageType::SpacingType;
229 using DirectionType = typename ImageType::DirectionType;
230 using OriginType = typename ImageType::PointType;
232
234 virtual void
235 SetGridRegion(const RegionType & region) = 0;
236
237 itkGetConstMacro(GridRegion, RegionType);
238
240 virtual void
241 SetGridSpacing(const SpacingType & spacing);
242
243 itkGetConstMacro(GridSpacing, SpacingType);
244
246 virtual void
247 SetGridDirection(const DirectionType & direction);
248
249 itkGetConstMacro(GridDirection, DirectionType);
250
252 virtual void
253 SetGridOrigin(const OriginType & origin);
254
255 itkGetConstMacro(GridOrigin, OriginType);
256
258 using ParameterIndexArrayType = Array<unsigned long>;
259
263 OutputVectorType
264 TransformVector(const InputVectorType &) const override
265 {
266 itkExceptionMacro(<< "Method not applicable for deformable transform.");
267 }
268
269
273 OutputVnlVectorType
274 TransformVector(const InputVnlVectorType &) const override
275 {
276 itkExceptionMacro(<< "Method not applicable for deformable transform. ");
277 }
278
279
283 OutputCovariantVectorType
284 TransformCovariantVector(const InputCovariantVectorType &) const override
285 {
286 itkExceptionMacro(<< "Method not applicable for deformable transform. ");
287 }
288
289
291 NumberOfParametersType
292 GetNumberOfParameters() const override;
293
295 virtual NumberOfParametersType
297
299 itkGetConstReferenceMacro(ValidRegion, RegionType);
300
306 bool
307 IsLinear() const override
308 {
309 return false;
310 }
311
315 TransformCategoryEnum
316 GetTransformCategory() const override
317 {
318 return TransformCategoryEnum::BSpline;
319 }
320
321
322 virtual unsigned int
324
325 NumberOfParametersType
327
331 using ContinuousIndexType = ContinuousIndex<ScalarType, SpaceDimension>;
332
333protected:
335 void
336 PrintSelf(std::ostream & os, Indent indent) const override;
337
339 explicit AdvancedBSplineDeformableTransformBase(const unsigned splineOrder);
341
343 void
345
348 TransformPointToContinuousGridIndex(const InputPointType & point) const;
349
350 void
352
353 virtual void
355 const RegionType & supportRegion) const = 0;
356
358 virtual bool
360
361private:
362 const unsigned m_SplineOrder;
363
364protected:
368 ImagePointer m_CoefficientImages[NDimensions];
369
371 RegionType m_GridRegion{};
372 SpacingType m_GridSpacing{ 1.0 }; // default spacing is all ones
373 DirectionType m_GridDirection{ DirectionType::GetIdentity() };
374 OriginType m_GridOrigin{};
375 GridOffsetType m_GridOffsetTable{};
376
381 FixedArray<ScalarType, NDimensions> m_PointToIndexMatrixDiagonal;
382 FixedArray<ScalarType, NDimensions * NDimensions> m_PointToIndexMatrixDiagonalProducts;
385
387
389 unsigned long m_Offset;
393
395 const ParametersType * m_InputParametersPointer;
396
398 using JacobianPixelType = typename JacobianType::ValueType;
400
401 typename JacobianImageType::Pointer m_JacobianImage[NDimensions];
402
407
409 ImagePointer m_WrappedImage[NDimensions];
410
413
414 void
416};
417
418} // namespace itk
419
420#ifndef ITK_MANUAL_INSTANTIATION
421# include "itkAdvancedBSplineDeformableTransformBase.hxx"
422#endif
423
424#endif /* itkAdvancedBSplineDeformableTransformBase_h */
Base class for deformable transform using a B-spline representation.
void SetParametersByValue(const ParametersType &parameters) override
const ParametersType & GetParameters() const override
virtual unsigned int GetNumberOfAffectedWeights() const =0
virtual void SetGridDirection(const DirectionType &direction)
virtual void SetGridRegion(const RegionType &region)=0
NumberOfParametersType GetNumberOfParameters() const override
void SetFixedParameters(const FixedParametersType &parameters) override
virtual void SetGridSpacing(const SpacingType &spacing)
AdvancedBSplineDeformableTransformBase(const unsigned splineOrder)
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const override
OutputVnlVectorType TransformVector(const InputVnlVectorType &) const override
itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions)
virtual void ComputeNonZeroJacobianIndices(NonZeroJacobianIndicesType &nonZeroJacobianIndices, const RegionType &supportRegion) const =0
virtual void SetCoefficientImages(ImagePointer images[])
NumberOfParametersType GetNumberOfNonZeroJacobianIndices() const override=0
void PrintSelf(std::ostream &os, Indent indent) const override
ITK_DISALLOW_COPY_AND_MOVE(AdvancedBSplineDeformableTransformBase)
virtual NumberOfParametersType GetNumberOfParametersPerDimension() const
FixedArray< ScalarType, NDimensions *NDimensions > m_PointToIndexMatrixDiagonalProducts
~AdvancedBSplineDeformableTransformBase() override=default
virtual bool InsideValidRegion(const ContinuousIndexType &index) const
ContinuousIndexType TransformPointToContinuousGridIndex(const InputPointType &point) const
OutputVectorType TransformVector(const InputVectorType &) const override
void SetParameters(const ParametersType &parameters) override
virtual void SetGridOrigin(const OriginType &origin)
const FixedParametersType & GetFixedParameters() const override
Transform maps points, vectors and covariant vectors from an input space to an output space.
typename SpatialJacobianType::InternalMatrixType InternalMatrixType
Matrix< ScalarType, OutputSpaceDimension, InputSpaceDimension > SpatialJacobianType
FixedArray< Matrix< ScalarType, InputSpaceDimension, InputSpaceDimension >, OutputSpaceDimension > SpatialHessianType
typename MovingImageGradientType::ValueType MovingImageGradientValueType


Generated on 2023-01-13 for elastix by doxygen 1.9.6 elastix logo