1
/*=========================================================================
3
* Copyright Insight Software Consortium
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
9
* http://www.apache.org/licenses/LICENSE-2.0.txt
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.
17
*=========================================================================*/
18
#ifndef sitkDisplacementFieldTransform_h
19
#define sitkDisplacementFieldTransform_h
21
#include "sitkCommon.h"
22
#include "sitkTransform.h"
23
#include "sitkInterpolator.h"
30
/** \brief A dense deformable transform over a bounded spatial domain
31
* for 2D or 3D coordinates space.
33
* \sa itk::DisplacementFieldTransform
35
class SITKCommon_EXPORT DisplacementFieldTransform
39
typedef DisplacementFieldTransform Self;
40
typedef Transform Superclass;
42
explicit DisplacementFieldTransform( unsigned int dimensions );
44
/** \brief Consume an image to construct a displacement field transform.
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.
50
* Image must be of sitkVectorFloat64 pixel type with the number of
51
* components equal to the image dimension.
54
explicit DisplacementFieldTransform( Image &);
56
DisplacementFieldTransform( const DisplacementFieldTransform & );
58
explicit DisplacementFieldTransform( const Transform & );
60
DisplacementFieldTransform &operator=( const DisplacementFieldTransform & );
62
/** Name of this class */
63
std::string GetName() const { return std::string ("DisplacementFieldTransform"); }
67
/** \brief Consume an image, and set the displacement field
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.
73
* Image must be of sitkVectorFloat64 pixel type with the number of
74
* components equal to the image dimension.
77
SITK_RETURN_SELF_TYPE_HEADER SetDisplacementField(Image &);
79
/** \todo The returned image should not directly modify the
80
* internal displacement field.
82
Image GetDisplacementField() const;
84
/** fixed parameter */
86
/* additional methods */
87
SITK_RETURN_SELF_TYPE_HEADER SetInverseDisplacementField(Image &);
89
/** \todo The returned image is should not directly modify the
90
* internal displacement field.
92
Image GetInverseDisplacementField() const;
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?
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 );
108
virtual void SetPimpleTransform( PimpleTransformBase *pimpleTransform );
112
using Superclass::AddTransform;
116
itk::TransformBase *transform;
117
DisplacementFieldTransform *that;
118
template< typename TransformType >
119
void operator() ( void ) const
121
TransformType *t = dynamic_cast<TransformType*>(transform);
122
if (t && (typeid(*t)==typeid(TransformType)))
124
that->InternalInitialization<TransformType>(t);
129
void InternalInitialization(itk::TransformBase *transform);
131
template <typename TransformType>
132
void InternalInitialization(TransformType *transform);
134
template< typename TDisplacementFieldTransform >
135
static Image InternalGetDisplacementField( const TDisplacementFieldTransform *itkDisplacementTx );
136
template< typename TDisplacementFieldTransform >
137
static Image InternalGetInverseDisplacementField( const TDisplacementFieldTransform *itkDisplacementTx );
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 );
153
static PimpleTransformBase *CreateDisplacementFieldPimpleTransform(unsigned int dimension);
155
nsstd::function<void (Image &)> m_pfSetDisplacementField;
156
nsstd::function<Image ()> m_pfGetDisplacementField;
158
nsstd::function<void (Image &)> m_pfSetInverseDisplacementField;
159
nsstd::function<Image ()> m_pfGetInverseDisplacementField;
161
nsstd::function<void (InterpolatorEnum &)> m_pfSetInterpolator;
162
nsstd::function<InterpolatorEnum ()> m_pfGetInterpolator;
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;
173
#endif // sitkDisplacementFieldTransform_h