SimpleITK  1.2.4
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 
37  : public Transform
38 {
39 public:
42 
43  virtual ~DisplacementFieldTransform();
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 { 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  virtual void SetPimpleTransform( PimpleTransformBase *pimpleTransform );
112 
113 private:
114 
115  using Superclass::AddTransform;
116 
117  struct MyVisitor
118  {
121  template< typename TransformType >
122  void operator() ( void ) const
123  {
124  TransformType *t = dynamic_cast<TransformType*>(transform);
125  if (t && (typeid(*t) == typeid(TransformType)))
126  {
127  that->InternalInitialization<TransformType>(t);
128  }
129  }
130  };
131 
132  void InternalInitialization(itk::TransformBase *transform);
133 
134  template <typename TransformType>
135  void InternalInitialization(TransformType *transform);
136 
137  template< typename TDisplacementFieldTransform >
138  static Image InternalGetDisplacementField( const TDisplacementFieldTransform *itkDisplacementTx );
139  template< typename TDisplacementFieldTransform >
140  static Image InternalGetInverseDisplacementField( const TDisplacementFieldTransform *itkDisplacementTx );
141 
142  template< typename TDisplacementFieldTransform >
143  void InternalSetSmoothingOff(TDisplacementFieldTransform *itkDisplacement);
144  template< typename TDisplacementFieldTransform >
145  void InternalSetSmoothingGaussianOnUpdate( TDisplacementFieldTransform *itkDisplacement,
146  double varianceForUpdateField,
147  double varianceForTotalField );
148  template< typename TDisplacementFieldTransform >
149  void InternalSetSmoothingBSplineOnUpdate( TDisplacementFieldTransform *itkDisplacement,
150  const std::vector<unsigned int> &numberOfControlPointsForUpdateField,
151  const std::vector<unsigned int> &numberOfControlPointsForTotalField,
152  bool enforceStationaryBoundary,
153  unsigned int order );
154 
155 
156  static PimpleTransformBase *CreateDisplacementFieldPimpleTransform(unsigned int dimension);
157 
158  nsstd::function<void (Image &)> m_pfSetDisplacementField;
159  nsstd::function<Image ()> m_pfGetDisplacementField;
160 
161  nsstd::function<void (Image &)> m_pfSetInverseDisplacementField;
162  nsstd::function<Image ()> m_pfGetInverseDisplacementField;
163 
164  nsstd::function<void (InterpolatorEnum &)> m_pfSetInterpolator;
165  nsstd::function<InterpolatorEnum ()> m_pfGetInterpolator;
166 
167  nsstd::function<void ()> m_pfSetSmoothingOff;
168  nsstd::function<void (double, double)> m_pfSetSmoothingGaussianOnUpdate;
169  nsstd::function<void (const std::vector<unsigned int> &,const std::vector<unsigned int>&, bool, unsigned int)> m_pfSetSmoothingBSplineOnUpdate;
170 
171 };
172 
173 }
174 }
175 
176 #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:84
nsstd::function< void(Image &)> m_pfSetDisplacementField
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
The Image class for SimpleITK.
Definition: sitkImage.h:78
nsstd::function< void(double, double)> m_pfSetSmoothingGaussianOnUpdate
nsstd::function< void(InterpolatorEnum &)> m_pfSetInterpolator
nsstd::function< InterpolatorEnum()> m_pfGetInterpolator