SimpleITK  1.1.0
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;
163 
164  nsstd::function<void (InterpolatorEnum &)> m_pfSetInterpolator;
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
itk::simple::Image
The main Image class for SimpleITK.
Definition: sitkImage.h:54
itk::simple::DisplacementFieldTransform::MyVisitor
Definition: sitkDisplacementFieldTransform.h:117
itk::simple::DisplacementFieldTransform::m_pfSetInverseDisplacementField
nsstd::function< void(Image &)> m_pfSetInverseDisplacementField
Definition: sitkDisplacementFieldTransform.h:161
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::DisplacementFieldTransform::m_pfGetInverseDisplacementField
nsstd::function< Image()> m_pfGetInverseDisplacementField
Definition: sitkDisplacementFieldTransform.h:162
itk::simple::Transform
A simplified wrapper around a variety of ITK transforms.
Definition: sitkTransform.h:84
itk::simple::DisplacementFieldTransform::MyVisitor::that
DisplacementFieldTransform * that
Definition: sitkDisplacementFieldTransform.h:120
sitkCommon.h
itk::simple::DisplacementFieldTransform::m_pfSetSmoothingGaussianOnUpdate
nsstd::function< void(double, double)> m_pfSetSmoothingGaussianOnUpdate
Definition: sitkDisplacementFieldTransform.h:168
itk::simple::DisplacementFieldTransform::MyVisitor::transform
itk::TransformBase * transform
Definition: sitkDisplacementFieldTransform.h:119
itk::simple::DisplacementFieldTransform::m_pfSetSmoothingOff
nsstd::function< void()> m_pfSetSmoothingOff
Definition: sitkDisplacementFieldTransform.h:167
itk::simple::DisplacementFieldTransform::GetName
std::string GetName() const
Definition: sitkDisplacementFieldTransform.h:66
SITKCommon_EXPORT
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
itk::simple::DisplacementFieldTransform::m_pfGetDisplacementField
nsstd::function< Image()> m_pfGetDisplacementField
Definition: sitkDisplacementFieldTransform.h:159
itk::simple::DisplacementFieldTransform::m_pfSetDisplacementField
nsstd::function< void(Image &)> m_pfSetDisplacementField
Definition: sitkDisplacementFieldTransform.h:158
itk::simple::DisplacementFieldTransform::m_pfSetSmoothingBSplineOnUpdate
nsstd::function< void(const std::vector< unsigned int > &, const std::vector< unsigned int > &, bool, unsigned int)> m_pfSetSmoothingBSplineOnUpdate
Definition: sitkDisplacementFieldTransform.h:169
sitkInterpolator.h
itk::simple::DisplacementFieldTransform::Superclass
Transform Superclass
Definition: sitkDisplacementFieldTransform.h:41
sitkTransform.h
itk::simple::DisplacementFieldTransform::Self
DisplacementFieldTransform Self
Definition: sitkDisplacementFieldTransform.h:40
itk::simple::DisplacementFieldTransform::m_pfSetInterpolator
nsstd::function< void(InterpolatorEnum &)> m_pfSetInterpolator
Definition: sitkDisplacementFieldTransform.h:164
itk
itk::TransformBaseTemplate
Definition: sitkTransform.h:37
itk::simple::DisplacementFieldTransform::m_pfGetInterpolator
nsstd::function< InterpolatorEnum()> m_pfGetInterpolator
Definition: sitkDisplacementFieldTransform.h:165