~ubuntu-branches/debian/sid/simpleitk/sid

« back to all changes in this revision

Viewing changes to Code/Common/include/sitkDisplacementFieldTransform.h

  • Committer: Package Import Robot
  • Author(s): Ghislain Antony Vaillant
  • Date: 2017-11-02 08:49:18 UTC
  • Revision ID: package-import@ubuntu.com-20171102084918-7hs09ih668xq87ej
Tags: upstream-1.0.1
ImportĀ upstreamĀ versionĀ 1.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
30
/** \brief A dense deformable transform over a bounded spatial domain
 
31
 * for 2D or 3D coordinates space.
 
32
 *
 
33
 * \sa itk::DisplacementFieldTransform
 
34
 */
 
35
class SITKCommon_EXPORT DisplacementFieldTransform
 
36
  : public Transform
 
37
{
 
38
public:
 
39
  typedef DisplacementFieldTransform Self;
 
40
  typedef Transform Superclass;
 
41
 
 
42
  explicit DisplacementFieldTransform( unsigned int dimensions );
 
43
 
 
44
  /** \brief Consume an image to construct a displacement field transform.
 
45
   *
 
46
   * \warning The input displacement image is transferred to the
 
47
   * constructed transform object. The input image is modified to be a
 
48
   * default constructed Image object.
 
49
   *
 
50
   * Image must be of sitkVectorFloat64 pixel type with the number of
 
51
   * components equal to the image dimension.
 
52
   *
 
53
   */
 
54
  explicit DisplacementFieldTransform( Image &);
 
55
 
 
56
  DisplacementFieldTransform( const DisplacementFieldTransform & );
 
57
 
 
58
  explicit DisplacementFieldTransform( const Transform & );
 
59
 
 
60
  DisplacementFieldTransform &operator=( const DisplacementFieldTransform & );
 
61
 
 
62
  /** Name of this class */
 
63
  std::string GetName() const { return std::string ("DisplacementFieldTransform"); }
 
64
 
 
65
  /** parameters */
 
66
 
 
67
  /** \brief Consume an image, and set the displacement field
 
68
   *
 
69
   * \warning The ownership of the input displacement image is
 
70
   * transferred to the constructed transform object. The input image
 
71
   * is modified to be a default constructed Image object.
 
72
   *
 
73
   * Image must be of sitkVectorFloat64 pixel type with the number of
 
74
   * components equal to the image dimension.
 
75
   *
 
76
   */
 
77
  SITK_RETURN_SELF_TYPE_HEADER SetDisplacementField(Image &);
 
78
 
 
79
  /** \todo The returned image should not directly modify the
 
80
   * internal displacement field.
 
81
   */
 
82
  Image GetDisplacementField() const;
 
83
 
 
84
  /** fixed parameter */
 
85
 
 
86
  /* additional methods */
 
87
  SITK_RETURN_SELF_TYPE_HEADER SetInverseDisplacementField(Image &);
 
88
 
 
89
  /** \todo The returned image is should not directly modify the
 
90
   * internal displacement field.
 
91
   */
 
92
  Image GetInverseDisplacementField() const;
 
93
 
 
94
  /** Set the interpolator used between the field voxels. */
 
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
  {
 
116
    itk::TransformBase *transform;
 
117
    DisplacementFieldTransform *that;
 
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