plastimatch
Loading...
Searching...
No Matches
xform.h
Go to the documentation of this file.
1/* -----------------------------------------------------------------------
2 See COPYRIGHT.TXT and LICENSE.TXT for copyright and license information
3 ----------------------------------------------------------------------- */
4#ifndef _xform_h_
5#define _xform_h_
6
7#include "plmbase_config.h"
8#include "itkTranslationTransform.h"
9#include "itkVersorRigid3DTransform.h"
10#include "itkQuaternionRigidTransform.h"
11#include "itkAffineTransform.h"
12#include "itkBSplineDeformableTransform.h"
13#include "itkThinPlateSplineKernelTransform.h"
14#include "itkSimilarity3DTransform.h"
15
16#include "itk_image_type.h"
17#include "smart_pointer.h"
18#include "volume.h"
19
20class Bspline_xform;
22class Volume_header;
23class Xform;
24class Xform_private;
25
39
40/* itk basic transforms */
41typedef itk::TranslationTransform < double, 3 > TranslationTransformType;
42typedef itk::VersorRigid3DTransform < double > VersorTransformType;
43typedef itk::QuaternionRigidTransform < double > QuaternionTransformType;
44typedef itk::AffineTransform < double, 3 > AffineTransformType;
45typedef itk::Similarity3DTransform<double> SimilarityTransformType;
46
47/* itk B-spline transforms */
48const unsigned int SplineDimension = 3;
49const unsigned int SplineOrder = 3;
50typedef itk::BSplineDeformableTransform <
52
53/* itk thin-plate transforms */
54typedef itk::ThinPlateSplineKernelTransform <
56typedef itk::ThinPlateSplineKernelTransform <
59
60
67public:
69 Xform_private *d_ptr;
70public:
71 Xform ();
72 ~Xform ();
73 Xform (const Xform& xf);
74
75public:
77
78 /* The actual xform is one of the following. */
79 TranslationTransformType::Pointer m_trn;
80 VersorTransformType::Pointer m_vrs;
81 AffineTransformType::Pointer m_aff;
82 QuaternionTransformType::Pointer m_quat;
83 DeformationFieldType::Pointer m_itk_vf;
84 BsplineTransformType::Pointer m_itk_bsp;
85 TpsTransformType::Pointer m_itk_tps;
86 SimilarityTransformType::Pointer m_similarity;
87
88public:
89 void clear ();
90
91 void load (const char* fn);
92 void load (const std::string& fn);
93 void save (const char* fn) const;
94 void save (const std::string& fn) const;
95
96 TranslationTransformType::Pointer get_trn () const;
97 VersorTransformType::Pointer get_vrs () const;
98 QuaternionTransformType::Pointer get_quat () const;
99 AffineTransformType::Pointer get_aff () const;
100 SimilarityTransformType::Pointer get_similarity() const;
101 BsplineTransformType::Pointer get_itk_bsp () const;
102 TpsTransformType::Pointer get_itk_tps () const;
103 DeformationFieldType::Pointer get_itk_vf () const;
104 Bspline_xform* get_gpuit_bsp () const;
105 Volume::Pointer& get_gpuit_vf () const;
106
107 void init_trn ();
108
109 void set_trn (const itk::Array<double>& trn);
110 void set_trn (TranslationTransformType::Pointer trn);
111 void set_vrs (const itk::Array<double>& vrs);
112 void set_vrs (VersorTransformType::Pointer vrs);
113 void set_quat (const itk::Array<double>& quat);
114 void set_quat (QuaternionTransformType::Pointer quat);
115 void set_aff (const itk::Array<double>& aff);
116 void set_aff (AffineTransformType::Pointer aff);
117 void set_similarity(SimilarityTransformType::Pointer sim);
118 void set_similarity(const itk::Array<double>& sim);
119 void set_itk_bsp (BsplineTransformType::Pointer bsp);
120 void set_itk_tps (TpsTransformType::Pointer tps);
121 void set_itk_vf (DeformationFieldType::Pointer vf);
122 void set_gpuit_bsp (Bspline_xform* xgb);
123 void set_gpuit_vf (const Volume::Pointer& vf);
124
125 void itk_bsp_set_grid (
126 const BsplineTransformType::OriginType bsp_origin,
127 const BsplineTransformType::SpacingType bsp_spacing,
128 const BsplineTransformType::RegionType bsp_region,
129 const BsplineTransformType::DirectionType bsp_direction);
130
131 Xform_type get_type () const;
132 void get_volume_header (Volume_header *vh);
133 Plm_image_header get_plm_image_header ();
134 void get_grid_spacing (float grid_spacing[3]);
135
138 bool is_linear ();
139
140 void print ();
141
142protected:
143 void save_gpuit_vf (const char* fn) const;
144
145public:
146 Xform& operator= (const Xform& xf);
147};
148
149
150PLMBASE_API Xform::Pointer xform_load (const std::string& fn);
151PLMBASE_API Xform::Pointer xform_load (const char* fn);
152PLMBASE_API void xform_load (Xform *xf, const std::string& fn);
153PLMBASE_API void xform_load (Xform *xf, const char* fn);
154PLMBASE_API void xform_save (Xform *xf, const std::string& fn);
155PLMBASE_API void xform_save (Xform *xf, const char* fn);
158 const BsplineTransformType::OriginType bsp_origin,
159 const BsplineTransformType::SpacingType bsp_spacing,
160 const BsplineTransformType::RegionType bsp_region,
161 const BsplineTransformType::DirectionType bsp_direction);
163 Xform *xf_out, const Xform *xf_in, Plm_image_header* pih);
165 Xform *xf_out, const Xform *xf_in, Plm_image_header* pih);
167 Xform *xf_out, const Xform *xf_in, Plm_image_header* pih);
169 Xform *xf_out, const Xform *xf_in, Plm_image_header* pih);
171 Xform *xf_out, const Xform *xf_in, Plm_image_header* pih);
172PLMBASE_API DeformationFieldType::Pointer xform_gpuit_vf_to_itk_vf (
173 Volume* vf, /* Input */
174 const Plm_image_header* pih /* Input, can be null */
175);
176PLMBASE_API void xform_to_itk_bsp (Xform *xf_out, const Xform *xf_in,
177 Plm_image_header* pih, const float* grid_spac);
178PLMBASE_API void xform_to_itk_bsp_nobulk (Xform *xf_out, Xform *xf_in, Plm_image_header* pih, const float* grid_spac);
179PLMBASE_API void xform_to_itk_vf (Xform* xf_out, Xform *xf_in, const Plm_image_header* pih);
180PLMBASE_API void xform_to_itk_vf (Xform* xf_out, Xform *xf_in, FloatImageType::Pointer image);
181PLMBASE_API void xform_to_gpuit_bsp (Xform* xf_out, Xform* xf_in, Plm_image_header* pih, const float* grid_spac);
182PLMBASE_API void xform_to_gpuit_vf (Xform* xf_out, const Xform *xf_in, const Plm_image_header* pih);
183
184PLMBASE_API Xform::Pointer xform_to_aff (const Xform::Pointer& xf_in);
185PLMBASE_API Xform::Pointer xform_to_itk_bsp (const Xform::Pointer& xf_in,
186 Plm_image_header* pih, const float* grid_spac);
187PLMBASE_API Xform::Pointer xform_to_itk_bsp_nobulk (const Xform::Pointer& xf_in, Plm_image_header* pih, const float* grid_spac);
188PLMBASE_API Xform::Pointer xform_to_itk_vf (const Xform::Pointer& xf_in, Plm_image_header* pih);
189PLMBASE_API Xform::Pointer xform_to_gpuit_bsp (const Xform::Pointer& xf_in, Plm_image_header* pih, float* grid_spac);
190PLMBASE_API Xform::Pointer xform_to_gpuit_vf (const Xform::Pointer& xf_in, const Plm_image_header* pih);
191
192#endif
The Bspline_xform class encapsulates the B-spline coefficients used by native registration and warpin...
Definition bspline_xform.h:24
The Plm_image_header class defines the geometry of an image. It defines image origin,...
Definition plm_image_header.h:24
Definition pointset.h:15
Definition volume_header.h:17
The Volume class represents a three-dimensional volume on a uniform grid. The volume can be located a...
Definition volume.h:38
The Xform class is an abstraction that encapsulates a simple transform, either native format (B-splin...
Definition xform.h:66
VersorTransformType::Pointer m_vrs
Definition xform.h:80
TpsTransformType::Pointer m_itk_tps
Definition xform.h:85
BsplineTransformType::Pointer m_itk_bsp
Definition xform.h:84
AffineTransformType::Pointer m_aff
Definition xform.h:81
QuaternionTransformType::Pointer m_quat
Definition xform.h:82
TranslationTransformType::Pointer m_trn
Definition xform.h:79
SimilarityTransformType::Pointer m_similarity
Definition xform.h:86
Xform_type m_type
Definition xform.h:76
Xform_private * d_ptr
Definition xform.h:69
SMART_POINTER_SUPPORT(Xform)
DeformationFieldType::Pointer m_itk_vf
Definition xform.h:83
#define PLMBASE_API
Definition plmbase_config.h:19
itk::ThinPlateSplineKernelTransform< float, 3 > FloatTpsTransformType
Definition xform.h:55
const unsigned int SplineDimension
Definition xform.h:48
itk::TranslationTransform< double, 3 > TranslationTransformType
Definition xform.h:41
void xform_to_gpuit_vf(Xform *xf_out, const Xform *xf_in, const Plm_image_header *pih)
Definition xform.cxx:1984
itk::AffineTransform< double, 3 > AffineTransformType
Definition xform.h:44
Xform::Pointer xform_load(const std::string &fn)
Definition xform.cxx:396
DoubleTpsTransformType TpsTransformType
Definition xform.h:58
void xform_to_gpuit_bsp(Xform *xf_out, Xform *xf_in, Plm_image_header *pih, const float *grid_spac)
Definition xform.cxx:1931
void xform_to_vrs(Xform *xf_out, const Xform *xf_in, Plm_image_header *pih)
Definition xform.cxx:1615
void xform_to_itk_bsp(Xform *xf_out, const Xform *xf_in, Plm_image_header *pih, const float *grid_spac)
Definition xform.cxx:1768
itk::BSplineDeformableTransform< double, SplineDimension, SplineOrder > BsplineTransformType
Definition xform.h:51
const unsigned int SplineOrder
Definition xform.h:49
void xform_to_itk_vf(Xform *xf_out, Xform *xf_in, const Plm_image_header *pih)
Definition xform.cxx:1868
void xform_itk_bsp_set_grid(Xform *xf, const BsplineTransformType::OriginType bsp_origin, const BsplineTransformType::SpacingType bsp_spacing, const BsplineTransformType::RegionType bsp_region, const BsplineTransformType::DirectionType bsp_direction)
itk::ThinPlateSplineKernelTransform< double, 3 > DoubleTpsTransformType
Definition xform.h:57
void xform_itk_bsp_init_default(Xform *xf)
Definition xform.cxx:633
void xform_to_quat(Xform *xf_out, const Xform *xf_in, Plm_image_header *pih)
Definition xform.cxx:1648
itk::Similarity3DTransform< double > SimilarityTransformType
Definition xform.h:45
itk::VersorRigid3DTransform< double > VersorTransformType
Definition xform.h:42
void xform_to_similarity(Xform *xf_out, const Xform *xf_in, Plm_image_header *pih)
Definition xform.cxx:1732
void xform_to_itk_bsp_nobulk(Xform *xf_out, Xform *xf_in, Plm_image_header *pih, const float *grid_spac)
Definition xform.cxx:1828
void xform_save(Xform *xf, const std::string &fn)
Definition xform.cxx:589
itk::QuaternionRigidTransform< double > QuaternionTransformType
Definition xform.h:43
Xform_type
Definition xform.h:26
@ XFORM_ITK_BSPLINE
Definition xform.h:33
@ XFORM_ITK_AFFINE
Definition xform.h:32
@ XFORM_ITK_VECTOR_FIELD
Definition xform.h:35
@ XFORM_GPUIT_VECTOR_FIELD
Definition xform.h:37
@ XFORM_NONE
Definition xform.h:27
@ XFORM_GPUIT_BSPLINE
Definition xform.h:36
@ XFORM_ITK_TRANSLATION
Definition xform.h:28
@ XFORM_ITK_QUATERNION
Definition xform.h:30
@ XFORM_ITK_SIMILARITY
Definition xform.h:31
@ XFORM_ITK_VERSOR
Definition xform.h:29
@ XFORM_ITK_TPS
Definition xform.h:34
void xform_to_trn(Xform *xf_out, const Xform *xf_in, Plm_image_header *pih)
Definition xform.cxx:1584
void xform_to_aff(Xform *xf_out, const Xform *xf_in, Plm_image_header *pih)
Definition xform.cxx:1682
DeformationFieldType::Pointer xform_gpuit_vf_to_itk_vf(Volume *vf, const Plm_image_header *pih)
Definition xform.cxx:1362