SimpleITK  
sitkDisplacementFieldTransform.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  * 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 sitkDisplacementFieldTransform_h
19 #define sitkDisplacementFieldTransform_h
20 
21 #include "sitkCommon.h"
22 #include "sitkTransform.h"
23 #include "sitkInterpolator.h"
24 
25 namespace itk::simple
26 {
27 
35 {
36 public:
39 
40  ~DisplacementFieldTransform() override;
41 
42  explicit DisplacementFieldTransform(unsigned int dimensions);
43 
55 
57 
58  explicit DisplacementFieldTransform(const Transform &);
59 
61  operator=(const DisplacementFieldTransform &);
62 
64  std::string
65  GetName() const override
66  {
67  return std::string("DisplacementFieldTransform");
68  }
69 
82  SITK_RETURN_SELF_TYPE_HEADER
83  SetDisplacementField(Image &);
84 
88  Image
89  GetDisplacementField() const;
90 
93  /* additional methods */
94  SITK_RETURN_SELF_TYPE_HEADER
95  SetInverseDisplacementField(Image &);
96 
100  Image
101  GetInverseDisplacementField() const;
102 
104  SITK_RETURN_SELF_TYPE_HEADER
105  SetInterpolator(InterpolatorEnum interp);
106  // InterpolatorEnum GetInterpolator() const; How to do this?
107 
108  SITK_RETURN_SELF_TYPE_HEADER
109  SetSmoothingOff();
110  SITK_RETURN_SELF_TYPE_HEADER
111  SetSmoothingGaussianOnUpdate(double varianceForUpdateField = 1.75, double varianceForTotalField = 0.5);
112  SITK_RETURN_SELF_TYPE_HEADER
113  SetSmoothingBSplineOnUpdate(
114  const std::vector<unsigned int> & numberOfControlPointsForUpdateField = std::vector<unsigned int>(3, 4),
115  const std::vector<unsigned int> & numberOfControlPointsForTotalField = std::vector<unsigned int>(3, 4),
116  bool enforceStationaryBoundary = true,
117  unsigned int order = 3);
118 
119 
120 protected:
121  void
122  SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform) override;
123 
124 private:
125  struct MyVisitor
126  {
129  template <typename TransformType>
130  void
131  operator()() const
132  {
133  TransformType * t = dynamic_cast<TransformType *>(transform);
134  if (t && (typeid(*t) == typeid(TransformType)))
135  {
136  that->InternalInitialization<TransformType>(t);
137  }
138  }
139  };
140 
141  void
142  InternalInitialization(itk::TransformBase * transform);
143 
144  template <typename TransformType>
145  void
146  InternalInitialization(TransformType * transform);
147 
148  template <typename TDisplacementFieldTransform>
149  static Image
150  InternalGetDisplacementField(const TDisplacementFieldTransform * itkDisplacementTx);
151  template <typename TDisplacementFieldTransform>
152  static Image
153  InternalGetInverseDisplacementField(const TDisplacementFieldTransform * itkDisplacementTx);
154 
155  template <typename TDisplacementFieldTransform>
156  void
157  InternalSetSmoothingOff(TDisplacementFieldTransform * itkDisplacement);
158  template <typename TDisplacementFieldTransform>
159  void
160  InternalSetSmoothingGaussianOnUpdate(TDisplacementFieldTransform * itkDisplacement,
161  double varianceForUpdateField,
162  double varianceForTotalField);
163  template <typename TDisplacementFieldTransform>
164  void
165  InternalSetSmoothingBSplineOnUpdate(TDisplacementFieldTransform * itkDisplacement,
166  const std::vector<unsigned int> & numberOfControlPointsForUpdateField,
167  const std::vector<unsigned int> & numberOfControlPointsForTotalField,
168  bool enforceStationaryBoundary,
169  unsigned int order);
170 
171 
172  static PimpleTransformBase *
173  CreateDisplacementFieldPimpleTransform(unsigned int dimension);
174 
175  std::function<void(Image &)> m_pfSetDisplacementField;
176  std::function<Image()> m_pfGetDisplacementField;
177 
178  std::function<void(Image &)> m_pfSetInverseDisplacementField;
180 
181  std::function<void(InterpolatorEnum &)> m_pfSetInterpolator;
183 
184  std::function<void()> m_pfSetSmoothingOff;
185  std::function<void(double, double)> m_pfSetSmoothingGaussianOnUpdate;
186  std::function<void(const std::vector<unsigned int> &, const std::vector<unsigned int> &, bool, unsigned int)>
188 };
189 
190 } // namespace itk::simple
191 
192 #endif // sitkDisplacementFieldTransform_h
itk::simple::Image
The Image class for SimpleITK.
Definition: sitkImage.h:76
itk::simple::DisplacementFieldTransform::m_pfSetInterpolator
std::function< void(InterpolatorEnum &)> m_pfSetInterpolator
Definition: sitkDisplacementFieldTransform.h:181
itk::simple::DisplacementFieldTransform::MyVisitor
Definition: sitkDisplacementFieldTransform.h:125
itk::simple::InterpolatorEnum
InterpolatorEnum
Definition: sitkInterpolator.h:28
itk::simple::DisplacementFieldTransform
A dense deformable transform over a bounded spatial domain for 2D or 3D coordinates space.
Definition: sitkDisplacementFieldTransform.h:34
itk::simple::DisplacementFieldTransform::InternalInitialization
void InternalInitialization(itk::TransformBase *transform)
itk::simple::Transform
A simplified wrapper around a variety of ITK transforms.
Definition: sitkTransform.h:86
itk::simple::DisplacementFieldTransform::MyVisitor::that
DisplacementFieldTransform * that
Definition: sitkDisplacementFieldTransform.h:128
sitkCommon.h
itk::simple::DisplacementFieldTransform::MyVisitor::transform
itk::TransformBase * transform
Definition: sitkDisplacementFieldTransform.h:127
itk::simple::DisplacementFieldTransform::m_pfSetSmoothingGaussianOnUpdate
std::function< void(double, double)> m_pfSetSmoothingGaussianOnUpdate
Definition: sitkDisplacementFieldTransform.h:185
itk::simple::DisplacementFieldTransform::m_pfGetDisplacementField
std::function< Image()> m_pfGetDisplacementField
Definition: sitkDisplacementFieldTransform.h:176
SITKCommon_EXPORT
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
itk::simple::DisplacementFieldTransform::m_pfGetInverseDisplacementField
std::function< Image()> m_pfGetInverseDisplacementField
Definition: sitkDisplacementFieldTransform.h:179
itk::simple::DisplacementFieldTransform::m_pfSetDisplacementField
std::function< void(Image &)> m_pfSetDisplacementField
Definition: sitkDisplacementFieldTransform.h:175
itk::simple::DisplacementFieldTransform::MyVisitor::operator()
void operator()() const
Definition: sitkDisplacementFieldTransform.h:131
sitkInterpolator.h
sitkTransform.h
itk::simple::DisplacementFieldTransform::m_pfSetSmoothingBSplineOnUpdate
std::function< void(const std::vector< unsigned int > &, const std::vector< unsigned int > &, bool, unsigned int)> m_pfSetSmoothingBSplineOnUpdate
Definition: sitkDisplacementFieldTransform.h:187
itk::simple::DisplacementFieldTransform::m_pfGetInterpolator
std::function< InterpolatorEnum()> m_pfGetInterpolator
Definition: sitkDisplacementFieldTransform.h:182
itk::simple::DisplacementFieldTransform::m_pfSetSmoothingOff
std::function< void()> m_pfSetSmoothingOff
Definition: sitkDisplacementFieldTransform.h:184
itk::simple
Definition: sitkAdditionalProcedures.h:28
itk::simple::DisplacementFieldTransform::m_pfSetInverseDisplacementField
std::function< void(Image &)> m_pfSetInverseDisplacementField
Definition: sitkDisplacementFieldTransform.h:178
itk::TransformBaseTemplate
Definition: sitkTransform.h:32
itk::simple::DisplacementFieldTransform::GetName
std::string GetName() const override
Definition: sitkDisplacementFieldTransform.h:65