SimpleITK  1.0.1
sitkDisplacementFieldTransform.h
Go to the documentation of this file.
1 /*=========================================================================
2 *
3 * Copyright Insight Software Consortium
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 
36  : public Transform
37 {
38 public:
41 
42  explicit DisplacementFieldTransform( unsigned int dimensions );
43 
54  explicit DisplacementFieldTransform( Image &);
55 
57 
58  explicit DisplacementFieldTransform( const Transform & );
59 
61 
63  std::string GetName() const { return std::string ("DisplacementFieldTransform"); }
64 
77  SITK_RETURN_SELF_TYPE_HEADER SetDisplacementField(Image &);
78 
82  Image GetDisplacementField() const;
83 
86  /* additional methods */
87  SITK_RETURN_SELF_TYPE_HEADER SetInverseDisplacementField(Image &);
88 
92  Image GetInverseDisplacementField() const;
93 
95  SITK_RETURN_SELF_TYPE_HEADER SetInterpolator(InterpolatorEnum interp);
96  // InterpolatorEnum GetInterpolator() const; How to do this?
97 
98  SITK_RETURN_SELF_TYPE_HEADER SetSmoothingOff();
99  SITK_RETURN_SELF_TYPE_HEADER SetSmoothingGaussianOnUpdate( double varianceForUpdateField=1.75, double varianceForTotalField=0.5 );
100  SITK_RETURN_SELF_TYPE_HEADER SetSmoothingBSplineOnUpdate( const std::vector<unsigned int> &numberOfControlPointsForUpdateField = std::vector<unsigned int>(3,4),
101  const std::vector<unsigned int> &numberOfControlPointsForTotalField = std::vector<unsigned int>(3,4),
102  bool enforceStationaryBoundary=true,
103  unsigned int order=3 );
104 
105 
106 protected:
107 
108  virtual void SetPimpleTransform( PimpleTransformBase *pimpleTransform );
109 
110 private:
111 
112  using Superclass::AddTransform;
113 
114  struct MyVisitor
115  {
118  template< typename TransformType >
119  void operator() ( void ) const
120  {
121  TransformType *t = dynamic_cast<TransformType*>(transform);
122  if (t && (typeid(*t)==typeid(TransformType)))
123  {
124  that->InternalInitialization<TransformType>(t);
125  }
126  }
127  };
128 
129  void InternalInitialization(itk::TransformBase *transform);
130 
131  template <typename TransformType>
132  void InternalInitialization(TransformType *transform);
133 
134  template< typename TDisplacementFieldTransform >
135  static Image InternalGetDisplacementField( const TDisplacementFieldTransform *itkDisplacementTx );
136  template< typename TDisplacementFieldTransform >
137  static Image InternalGetInverseDisplacementField( const TDisplacementFieldTransform *itkDisplacementTx );
138 
139  template< typename TDisplacementFieldTransform >
140  void InternalSetSmoothingOff(TDisplacementFieldTransform *itkDisplacement);
141  template< typename TDisplacementFieldTransform >
142  void InternalSetSmoothingGaussianOnUpdate( TDisplacementFieldTransform *itkDisplacement,
143  double varianceForUpdateField,
144  double varianceForTotalField );
145  template< typename TDisplacementFieldTransform >
146  void InternalSetSmoothingBSplineOnUpdate( TDisplacementFieldTransform *itkDisplacement,
147  const std::vector<unsigned int> &numberOfControlPointsForUpdateField,
148  const std::vector<unsigned int> &numberOfControlPointsForTotalField,
149  bool enforceStationaryBoundary,
150  unsigned int order );
151 
152 
153  static PimpleTransformBase *CreateDisplacementFieldPimpleTransform(unsigned int dimension);
154 
155  nsstd::function<void (Image &)> m_pfSetDisplacementField;
156  nsstd::function<Image ()> m_pfGetDisplacementField;
157 
158  nsstd::function<void (Image &)> m_pfSetInverseDisplacementField;
159  nsstd::function<Image ()> m_pfGetInverseDisplacementField;
160 
161  nsstd::function<void (InterpolatorEnum &)> m_pfSetInterpolator;
162  nsstd::function<InterpolatorEnum ()> m_pfGetInterpolator;
163 
164  nsstd::function<void ()> m_pfSetSmoothingOff;
165  nsstd::function<void (double, double)> m_pfSetSmoothingGaussianOnUpdate;
166  nsstd::function<void (const std::vector<unsigned int> &,const std::vector<unsigned int>&, bool, unsigned int)> m_pfSetSmoothingBSplineOnUpdate;
167 
168 };
169 
170 }
171 }
172 
173 #endif // sitkDisplacementFieldTransform_h
void InternalInitialization(itk::TransformBase *transform)
nsstd::function< void(Image &)> m_pfSetInverseDisplacementField
A dense deformable transform over a bounded spatial domain for 2D or 3D coordinates space...
A simplified wrapper around a variety of ITK transforms.
Definition: sitkTransform.h:83
nsstd::function< void(Image &)> m_pfSetDisplacementField
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
The main Image class for SimpleITK.
Definition: sitkImage.h:54
nsstd::function< void(double, double)> m_pfSetSmoothingGaussianOnUpdate
nsstd::function< void(InterpolatorEnum &)> m_pfSetInterpolator
nsstd::function< InterpolatorEnum()> m_pfGetInterpolator