ITK  5.4.0
Insight Toolkit
itkBSplineDeformableTransform.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 itkBSplineDeformableTransform_h
19 #define itkBSplineDeformableTransform_h
20 
22 
23 namespace itk
24 {
112 template <typename TParametersValueType = double, unsigned int VDimension = 3, unsigned int VSplineOrder = 3>
113 class ITK_TEMPLATE_EXPORT BSplineDeformableTransform
114  : public BSplineBaseTransform<TParametersValueType, VDimension, VSplineOrder>
115 {
116 public:
117  ITK_DISALLOW_COPY_AND_MOVE(BSplineDeformableTransform);
118 
124 
126  // Explicit New() method, used here because we need to split the itkNewMacro()
127  // in order to overload the CreateAnother() method so that we can copy the m_BulkTransform
128  // explicitly.
129  // TODO: shouldn't it be done with the Clone() method?
130  itkSimpleNewMacro(Self);
132  CreateAnother() const override
133  {
134  itk::LightObject::Pointer smartPtr;
135  Pointer copyPtr = Self::New().GetPointer();
136  // THE FOLLOWING LINE IS DIFFERENT FROM THE DEFAULT MACRO!
137  copyPtr->m_BulkTransform = this->GetBulkTransform();
138  smartPtr = static_cast<Pointer>(copyPtr);
139  return smartPtr;
140  }
144  itkCloneMacro(Self);
145 
147  itkOverrideGetNameOfClassMacro(BSplineDeformableTransform);
148 
150  static constexpr unsigned int SpaceDimension = VDimension;
151 
153  static constexpr unsigned int SplineOrder = VSplineOrder;
154 
156  using ScalarType = TParametersValueType;
157 
159  using typename Superclass::ParametersType;
160  using typename Superclass::ParametersValueType;
161  using typename Superclass::FixedParametersType;
162  using typename Superclass::FixedParametersValueType;
163 
165  using typename Superclass::JacobianType;
166  using typename Superclass::JacobianPositionType;
167  using typename Superclass::InverseJacobianPositionType;
168 
170  using typename Superclass::NumberOfParametersType;
171 
173  using typename Superclass::InputVectorType;
174  using typename Superclass::OutputVectorType;
175 
177  using typename Superclass::InputCovariantVectorType;
178  using typename Superclass::OutputCovariantVectorType;
179 
181  using typename Superclass::InputVnlVectorType;
182  using typename Superclass::OutputVnlVectorType;
183 
187 
188 
205  void
206  SetFixedParameters(const FixedParametersType & passedParameters) override;
210  using typename Superclass::ImageType;
211  using typename Superclass::ImagePointer;
212  using typename Superclass::CoefficientImageArray;
213 
225  void
226  SetCoefficientImages(const CoefficientImageArray & images) override;
227 
229  using typename Superclass::RegionType;
230 
231  using typename Superclass::IndexType;
232  using typename Superclass::SizeType;
233  using typename Superclass::SpacingType;
234  using typename Superclass::DirectionType;
235  using typename Superclass::OriginType;
236 
238  using typename Superclass::WeightsFunctionType;
239 
240  using typename Superclass::WeightsType;
241  using typename Superclass::ContinuousIndexType;
242 
244  using typename Superclass::ParameterIndexArrayType;
245 
254  using Superclass::TransformPoint;
255  void
256  TransformPoint(const InputPointType & inputPoint,
257  OutputPointType & outputPoint,
258  WeightsType & weights,
259  ParameterIndexArrayType & indices,
260  bool & inside) const override;
263  void
264  ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType &) const override;
265 
268  GetNumberOfParameters() const override;
269 
272  GetNumberOfParametersPerDimension() const override;
273 
274  using PhysicalDimensionsType = typename Superclass::SpacingType;
275  using typename Superclass::PixelType;
276 
277  using typename Superclass::MeshSizeType;
278 
280  virtual void
281  SetGridOrigin(const OriginType &);
282 
284  itkGetConstMacro(GridOrigin, OriginType);
285 
287  virtual void
288  SetGridSpacing(const SpacingType &);
289 
291  itkGetConstMacro(GridSpacing, SpacingType);
292 
294  virtual void
295  SetGridDirection(const DirectionType &);
296 
298  itkGetConstMacro(GridDirection, DirectionType);
299 
301  virtual void
302  SetGridRegion(const RegionType &);
303 
305  itkGetConstMacro(GridRegion, RegionType);
306 
312  itkSetConstObjectMacro(BulkTransform, BulkTransformType);
313  itkGetConstObjectMacro(BulkTransform, BulkTransformType);
317  itkGetConstReferenceMacro(ValidRegion, RegionType);
318 
319 protected:
321  void
322  PrintSelf(std::ostream & os, Indent indent) const override;
323 
325  ~BSplineDeformableTransform() override = default;
326 
327 private:
329  void
330  SetFixedParametersGridSizeFromTransformDomainInformation() const override;
331 
333  void
334  SetFixedParametersGridOriginFromTransformDomainInformation() const override;
335 
337  void
338  SetFixedParametersGridSpacingFromTransformDomainInformation() const override;
339 
341  void
342  SetFixedParametersGridDirectionFromTransformDomainInformation() const override;
343 
345  void
346  SetCoefficientImageInformationFromFixedParameters() override;
347 
349  bool
350  InsideValidRegion(ContinuousIndexType &) const override;
351 
360  const RegionType & m_GridRegion{};
361  const OriginType & m_GridOrigin{};
362  const SpacingType & m_GridSpacing{};
364 
366  BulkTransformPointer m_BulkTransform{};
367 
368  RegionType m_ValidRegion{};
369 
371  unsigned long m_Offset{};
372  bool m_SplineOrderOdd{};
373  IndexType m_ValidRegionLast{};
374  IndexType m_ValidRegionFirst{};
375 
376  void
377  UpdateValidGridRegion();
378 
379 }; // class BSplineDeformableTransform
380 } // namespace itk
381 
382 #ifndef ITK_MANUAL_INSTANTIATION
383 # include "itkBSplineDeformableTransform.hxx"
384 #endif
385 
386 #endif /* itkBSplineDeformableTransform_h */
itk::BSplineDeformableTransform::m_GridDirection
const DirectionType & m_GridDirection
Definition: itkBSplineDeformableTransform.h:363
itk::OptimizerParameters
Class to hold and manage different parameter types used during optimization.
Definition: itkOptimizerParameters.h:36
itk::BSplineDeformableTransform
Deformable transform using a BSpline representation.
Definition: itkBSplineDeformableTransform.h:113
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
itk::BSplineBaseTransform::PhysicalDimensionsType
typename ImageType::SpacingType PhysicalDimensionsType
Definition: itkBSplineBaseTransform.h:327
itk::BSplineBaseTransform::WeightsType
typename WeightsFunctionType::WeightsType WeightsType
Definition: itkBSplineBaseTransform.h:235
itk::BSplineBaseTransform::DirectionType
typename ImageType::DirectionType DirectionType
Definition: itkBSplineBaseTransform.h:225
itk::BSplineBaseTransform::SpacingType
typename ImageType::SpacingType SpacingType
Definition: itkBSplineBaseTransform.h:224
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::BSplineBaseTransform::OriginType
typename ImageType::PointType OriginType
Definition: itkBSplineBaseTransform.h:226
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::FixedArray< ImagePointer, VDimension >
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkBSplineBaseTransform.h
itk::BSplineDeformableTransform::ScalarType
TParametersValueType ScalarType
Definition: itkBSplineDeformableTransform.h:156
itk::BSplineBaseTransform
A base class with common elements of BSplineTransform and BSplineDeformableTransform.
Definition: itkBSplineBaseTransform.h:34
itk::BSplineDeformableTransform::CreateAnother
itk::LightObject::Pointer CreateAnother() const override
Definition: itkBSplineDeformableTransform.h:132
itk::Point
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:53
itk::TransformBaseTemplate::NumberOfParametersType
IdentifierType NumberOfParametersType
Definition: itkTransformBase.h:91
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:83
itk::BSplineDeformableTransform::BulkTransformPointer
typename BulkTransformType::ConstPointer BulkTransformPointer
Definition: itkBSplineDeformableTransform.h:308
New
static Pointer New()
AddImageFilter
Definition: itkAddImageFilter.h:81
itk::BSplineBaseTransform::ContinuousIndexType
typename WeightsFunctionType::ContinuousIndexType ContinuousIndexType
Definition: itkBSplineBaseTransform.h:236
itk::Array2D
Array2D class representing a 2D array.
Definition: itkArray2D.h:42
itk::images
*par Constraints *The filter requires an image with at least two dimensions and a vector *length of at least The theory supports extension to scalar images
Definition: itkVectorGradientMagnitudeImageFilter.h:107