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  : public Transform
36 {
37 public:
40 
41  ~DisplacementFieldTransform() override;
42 
43  explicit DisplacementFieldTransform( unsigned int dimensions );
44 
55  explicit DisplacementFieldTransform( Image &);
56 
58 
59  explicit DisplacementFieldTransform( const Transform & );
60 
62 
64  std::string GetName() const override { return std::string ("DisplacementFieldTransform"); }
65 
78  SITK_RETURN_SELF_TYPE_HEADER SetDisplacementField(Image &);
79 
83  Image GetDisplacementField() const;
84 
87  /* additional methods */
88  SITK_RETURN_SELF_TYPE_HEADER SetInverseDisplacementField(Image &);
89 
93  Image GetInverseDisplacementField() const;
94 
96  SITK_RETURN_SELF_TYPE_HEADER SetInterpolator(InterpolatorEnum interp);
97  // InterpolatorEnum GetInterpolator() const; How to do this?
98 
99  SITK_RETURN_SELF_TYPE_HEADER SetSmoothingOff();
100  SITK_RETURN_SELF_TYPE_HEADER SetSmoothingGaussianOnUpdate( double varianceForUpdateField=1.75, double varianceForTotalField=0.5 );
101  SITK_RETURN_SELF_TYPE_HEADER SetSmoothingBSplineOnUpdate( const std::vector<unsigned int> &numberOfControlPointsForUpdateField = std::vector<unsigned int>(3,4),
102  const std::vector<unsigned int> &numberOfControlPointsForTotalField = std::vector<unsigned int>(3,4),
103  bool enforceStationaryBoundary=true,
104  unsigned int order=3 );
105 
106 
107 protected:
108 
109  void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;
110 
111 private:
112 
113  struct MyVisitor
114  {
117  template< typename TransformType >
118  void operator() ( ) const
119  {
120  TransformType *t = dynamic_cast<TransformType*>(transform);
121  if (t && (typeid(*t) == typeid(TransformType)))
122  {
123  that->InternalInitialization<TransformType>(t);
124  }
125  }
126  };
127 
128  void InternalInitialization(itk::TransformBase *transform);
129 
130  template <typename TransformType>
131  void InternalInitialization(TransformType *transform);
132 
133  template< typename TDisplacementFieldTransform >
134  static Image InternalGetDisplacementField( const TDisplacementFieldTransform *itkDisplacementTx );
135  template< typename TDisplacementFieldTransform >
136  static Image InternalGetInverseDisplacementField( const TDisplacementFieldTransform *itkDisplacementTx );
137 
138  template< typename TDisplacementFieldTransform >
139  void InternalSetSmoothingOff(TDisplacementFieldTransform *itkDisplacement);
140  template< typename TDisplacementFieldTransform >
141  void InternalSetSmoothingGaussianOnUpdate( TDisplacementFieldTransform *itkDisplacement,
142  double varianceForUpdateField,
143  double varianceForTotalField );
144  template< typename TDisplacementFieldTransform >
145  void InternalSetSmoothingBSplineOnUpdate( TDisplacementFieldTransform *itkDisplacement,
146  const std::vector<unsigned int> &numberOfControlPointsForUpdateField,
147  const std::vector<unsigned int> &numberOfControlPointsForTotalField,
148  bool enforceStationaryBoundary,
149  unsigned int order );
150 
151 
152  static PimpleTransformBase *CreateDisplacementFieldPimpleTransform(unsigned int dimension);
153 
154  std::function<void (Image &)> m_pfSetDisplacementField;
155  std::function<Image ()> m_pfGetDisplacementField;
156 
157  std::function<void (Image &)> m_pfSetInverseDisplacementField;
159 
160  std::function<void (InterpolatorEnum &)> m_pfSetInterpolator;
162 
163  std::function<void ()> m_pfSetSmoothingOff;
164  std::function<void (double, double)> m_pfSetSmoothingGaussianOnUpdate;
165  std::function<void (const std::vector<unsigned int> &,const std::vector<unsigned int>&, bool, unsigned int)> m_pfSetSmoothingBSplineOnUpdate;
166 
167 };
168 
169 }
170 
171 #endif // sitkDisplacementFieldTransform_h
itk::simple::Image
The Image class for SimpleITK.
Definition: sitkImage.h:76
itk::simple::DisplacementFieldTransform::MyVisitor
Definition: sitkDisplacementFieldTransform.h:113
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:81
itk::simple::DisplacementFieldTransform::MyVisitor::that
DisplacementFieldTransform * that
Definition: sitkDisplacementFieldTransform.h:116
sitkCommon.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:165
itk::simple::DisplacementFieldTransform::m_pfSetSmoothingOff
std::function< void()> m_pfSetSmoothingOff
Definition: sitkDisplacementFieldTransform.h:163
itk::simple::DisplacementFieldTransform::MyVisitor::transform
itk::TransformBase * transform
Definition: sitkDisplacementFieldTransform.h:115
itk::simple::DisplacementFieldTransform::m_pfSetInverseDisplacementField
std::function< void(Image &)> m_pfSetInverseDisplacementField
Definition: sitkDisplacementFieldTransform.h:157
itk::simple::DisplacementFieldTransform::m_pfGetDisplacementField
std::function< Image()> m_pfGetDisplacementField
Definition: sitkDisplacementFieldTransform.h:155
SITKCommon_EXPORT
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
sitkInterpolator.h
itk::simple::DisplacementFieldTransform::m_pfGetInterpolator
std::function< InterpolatorEnum()> m_pfGetInterpolator
Definition: sitkDisplacementFieldTransform.h:161
sitkTransform.h
itk::simple::DisplacementFieldTransform::m_pfSetInterpolator
std::function< void(InterpolatorEnum &)> m_pfSetInterpolator
Definition: sitkDisplacementFieldTransform.h:160
itk::simple::DisplacementFieldTransform::m_pfSetSmoothingGaussianOnUpdate
std::function< void(double, double)> m_pfSetSmoothingGaussianOnUpdate
Definition: sitkDisplacementFieldTransform.h:164
itk::simple
Definition: sitkAdditionalProcedures.h:28
itk::TransformBaseTemplate
Definition: sitkTransform.h:30
itk::simple::DisplacementFieldTransform::GetName
std::string GetName() const override
Definition: sitkDisplacementFieldTransform.h:64
itk::simple::DisplacementFieldTransform::m_pfGetInverseDisplacementField
std::function< Image()> m_pfGetInverseDisplacementField
Definition: sitkDisplacementFieldTransform.h:158
itk::simple::DisplacementFieldTransform::m_pfSetDisplacementField
std::function< void(Image &)> m_pfSetDisplacementField
Definition: sitkDisplacementFieldTransform.h:154