SimpleITK  
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
25namespace itk::simple
26{
27
35{
36public:
39
41
42 explicit DisplacementFieldTransform(unsigned int dimensions);
43
55
57
59
62
64 std::string
65 GetName() const override
66 {
67 return std::string("DisplacementFieldTransform");
68 }
69
71
82 SITK_RETURN_SELF_TYPE_HEADER
84
88 Image
90
92
93 /* additional methods */
94 SITK_RETURN_SELF_TYPE_HEADER
96
100 Image
102
104 SITK_RETURN_SELF_TYPE_HEADER
106 // InterpolatorEnum GetInterpolator() const; How to do this?
107
108 SITK_RETURN_SELF_TYPE_HEADER
110 SITK_RETURN_SELF_TYPE_HEADER
111 SetSmoothingGaussianOnUpdate(double varianceForUpdateField = 1.75, double varianceForTotalField = 0.5);
112 SITK_RETURN_SELF_TYPE_HEADER
114 const std::vector<unsigned int> & numberOfControlPointsForUpdateField = std::vector<unsigned int>(3, 4),
115 const std::vector<unsigned int> & numberOfControlPointsForTotalField = std::vector<unsigned int>(3, 4),
116 bool enforceStationaryBoundary = true,
117 unsigned int order = 3);
118
119
120protected:
121 void
122 SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform) override;
123
124private:
126 {
129 template <typename TransformType>
130 void
132 {
133 TransformType * t = dynamic_cast<TransformType *>(transform);
134 if (t && (typeid(*t) == typeid(TransformType)))
135 {
136 that->InternalInitialization<TransformType>(t);
137 }
138 }
139 };
140
141 void
143
144 template <typename TransformType>
145 void
146 InternalInitialization(TransformType * transform);
147
148 template <typename TDisplacementFieldTransform>
149 static Image
150 InternalGetDisplacementField(const TDisplacementFieldTransform * itkDisplacementTx);
151 template <typename TDisplacementFieldTransform>
152 static Image
153 InternalGetInverseDisplacementField(const TDisplacementFieldTransform * itkDisplacementTx);
154
155 template <typename TDisplacementFieldTransform>
156 void
157 InternalSetSmoothingOff(TDisplacementFieldTransform * itkDisplacement);
158 template <typename TDisplacementFieldTransform>
159 void
160 InternalSetSmoothingGaussianOnUpdate(TDisplacementFieldTransform * itkDisplacement,
161 double varianceForUpdateField,
162 double varianceForTotalField);
163 template <typename TDisplacementFieldTransform>
164 void
165 InternalSetSmoothingBSplineOnUpdate(TDisplacementFieldTransform * itkDisplacement,
166 const std::vector<unsigned int> & numberOfControlPointsForUpdateField,
167 const std::vector<unsigned int> & numberOfControlPointsForTotalField,
168 bool enforceStationaryBoundary,
169 unsigned int order);
170
171
172 static PimpleTransformBase *
174
175 std::function<void(Image &)> m_pfSetDisplacementField;
177
180
181 std::function<void(InterpolatorEnum &)> m_pfSetInterpolator;
183
184 std::function<void()> m_pfSetSmoothingOff;
185 std::function<void(double, double)> m_pfSetSmoothingGaussianOnUpdate;
186 std::function<void(const std::vector<unsigned int> &, const std::vector<unsigned int> &, bool, unsigned int)>
188};
189
190} // namespace itk::simple
191
192#endif // sitkDisplacementFieldTransform_h
Self & SetSmoothingGaussianOnUpdate(double varianceForUpdateField=1.75, double varianceForTotalField=0.5)
DisplacementFieldTransform(unsigned int dimensions)
std::function< void(InterpolatorEnum &)> m_pfSetInterpolator
static Image InternalGetInverseDisplacementField(const TDisplacementFieldTransform *itkDisplacementTx)
DisplacementFieldTransform(Image &)
Consume an image to construct a displacement field transform.
static Image InternalGetDisplacementField(const TDisplacementFieldTransform *itkDisplacementTx)
void InternalSetSmoothingBSplineOnUpdate(TDisplacementFieldTransform *itkDisplacement, const std::vector< unsigned int > &numberOfControlPointsForUpdateField, const std::vector< unsigned int > &numberOfControlPointsForTotalField, bool enforceStationaryBoundary, unsigned int order)
Self & SetInterpolator(InterpolatorEnum interp)
std::function< void(Image &)> m_pfSetInverseDisplacementField
DisplacementFieldTransform & operator=(const DisplacementFieldTransform &)
void SetPimpleTransform(std::unique_ptr< PimpleTransformBase > &&pimpleTransform) override
Self & SetDisplacementField(Image &)
Consume an image, and set the displacement field.
std::function< void(double, double)> m_pfSetSmoothingGaussianOnUpdate
void InternalInitialization(TransformType *transform)
Self & SetSmoothingBSplineOnUpdate(const std::vector< unsigned int > &numberOfControlPointsForUpdateField=std::vector< unsigned int >(3, 4), const std::vector< unsigned int > &numberOfControlPointsForTotalField=std::vector< unsigned int >(3, 4), bool enforceStationaryBoundary=true, unsigned int order=3)
void InternalSetSmoothingOff(TDisplacementFieldTransform *itkDisplacement)
void InternalSetSmoothingGaussianOnUpdate(TDisplacementFieldTransform *itkDisplacement, double varianceForUpdateField, double varianceForTotalField)
std::function< InterpolatorEnum()> m_pfGetInterpolator
DisplacementFieldTransform(const DisplacementFieldTransform &)
void InternalInitialization(itk::TransformBase *transform)
std::function< void(const std::vector< unsigned int > &, const std::vector< unsigned int > &, bool, unsigned int)> m_pfSetSmoothingBSplineOnUpdate
static PimpleTransformBase * CreateDisplacementFieldPimpleTransform(unsigned int dimension)
DisplacementFieldTransform(const Transform &)
The Image class for SimpleITK.
Definition sitkImage.h:77
Transform()
By default a 3-d identity transform is constructed.
TransformBaseTemplate< double > TransformBase
#define SITKCommon_EXPORT
Definition sitkCommon.h:41