go home Home | Main Page | Topics | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
Loading...
Searching...
No Matches
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 <typename 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
188
190 const ParametersType &
191 GetParameters() const override;
192
194 const FixedParametersType &
195 GetFixedParameters() const override;
196
198 using PixelType = typename ParametersType::ValueType;
199 using ImageType = Image<PixelType, Self::SpaceDimension>;
200 using ImagePointer = typename ImageType::Pointer;
201
203 const ImagePointer *
205 {
206 return m_CoefficientImages.data();
207 }
208
220 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
303 bool
304 IsLinear() const override
305 {
306 return false;
307 }
308
312 TransformCategoryEnum
313 GetTransformCategory() const override
314 {
315 return TransformCategoryEnum::BSpline;
316 }
317
318
319 virtual unsigned int
321
322 NumberOfParametersType
324
328 using ContinuousIndexType = ContinuousIndex<ScalarType, SpaceDimension>;
329
330protected:
332 void
333 PrintSelf(std::ostream & os, Indent indent) const override;
334
336 explicit AdvancedBSplineDeformableTransformBase(const unsigned splineOrder);
338
340 void
342
345 TransformPointToContinuousGridIndex(const InputPointType & point) const;
346
347 void
349
350 virtual void
352 const RegionType & supportRegion) const = 0;
353
355 virtual bool
357
358private:
359 const unsigned m_SplineOrder{};
360
361 // Private using-declarations, to avoid `-Woverloaded-virtual` warnings from GCC (GCC 11.4) or clang (macos-12).
362 using Superclass::TransformVector;
363 using Superclass::TransformCovariantVector;
364
365protected:
369 FixedArray<ImagePointer, NDimensions> m_CoefficientImages{};
370
373 SpacingType m_GridSpacing{ 1.0 }; // default spacing is all ones
374 DirectionType m_GridDirection{ DirectionType::GetIdentity() };
377
382 FixedArray<ScalarType, NDimensions> m_PointToIndexMatrixDiagonal{};
383 FixedArray<ScalarType, NDimensions * NDimensions> m_PointToIndexMatrixDiagonalProducts{};
386
390
392 using JacobianPixelType = typename JacobianType::ValueType;
393 using JacobianImageType = Image<JacobianPixelType, Self::SpaceDimension>;
394
396 FixedArray<ImagePointer, NDimensions> m_WrappedImage{};
397
400
403
404 void
406};
407
408} // namespace itk
409
410#ifndef ITK_MANUAL_INSTANTIATION
411# include "itkAdvancedBSplineDeformableTransformBase.hxx"
412#endif
413
414#endif /* itkAdvancedBSplineDeformableTransformBase_h */
void SetParametersByValue(const ParametersType &parameters) override
const ParametersType & GetParameters() const override
Matrix< ScalarType, OutputSpaceDimension, InputSpaceDimension > SpatialJacobianType
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)
itkOverrideGetNameOfClassMacro(AdvancedBSplineDeformableTransformBase)
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
NumberOfParametersType GetNumberOfNonZeroJacobianIndices() const override=0
void PrintSelf(std::ostream &os, Indent indent) const override
ITK_DISALLOW_COPY_AND_MOVE(AdvancedBSplineDeformableTransformBase)
virtual NumberOfParametersType GetNumberOfParametersPerDimension() const
~AdvancedBSplineDeformableTransformBase() override=default
virtual bool InsideValidRegion(const ContinuousIndexType &index) const
void SetCoefficientImages(ImagePointer images[])
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
typename SpatialJacobianType::InternalMatrixType InternalMatrixType
FixedArray< Matrix< ScalarType, InputSpaceDimension, InputSpaceDimension >, OutputSpaceDimension > SpatialHessianType
Matrix< ScalarType, OutputSpaceDimension, InputSpaceDimension > SpatialJacobianType
typename MovingImageGradientType::ValueType MovingImageGradientValueType


Generated on 1774142652 for elastix by doxygen 1.15.0 elastix logo