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