stackdisttrans.hh
Go to the documentation of this file.
1 /* -*- mia-c++ -*-
2  *
3  * This file is part of MIA - a toolbox for medical image analysis
4  * Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
5  *
6  * MIA is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef mia_3d_stackdisttrans_hh
22 #define mia_3d_stackdisttrans_hh
23 
24 #include <vector>
25 #include <mia/3d/defines3d.hh>
26 #include <mia/3d/vector.hh>
27 #include <mia/2d/image.hh>
28 #include <mia/core/iohandler.hh>
29 #include <mia/core/ioplugin.hh>
30 
32 
48 public:
51 
53  static const char * const data_descr;
54 
56  static const char * const type_descr;
57 
58 
63 
69  DistanceFromPoint(C3DBounds _point, float _distance):
70  point(_point),
71  distance(_distance)
72  {};
74  float distance;
75  };
76 
77 
78  C2DStackDistanceTransform() = default;
79 
83  C2DStackDistanceTransform(const C2DStackDistanceTransform& /*other*/) = default;
84 
88  C2DStackDistanceTransform *clone() const __attribute__((warn_unused_result));
89 
96  C2DStackDistanceTransform(const C2DImage& slice, const C3DFVector& voxel_size = C3DFVector::_1);
97 
104  void read( const C2DImage& slice, int q);
105 
106 
113  std::vector<DistanceFromPoint> get_slice(size_t s, const C2DImage& image) const;
114 
120  bool save(const std::string& filename);
121 
122 private:
123 
124  float d(float fq, float q, float fv, float v)const;
125 
126  void dt1d(std::vector<float>& f, float scale)const;
127  void dt2d(C2DFImage& image)const;
128 
129  struct SParabola {
130  int k;
131  int v;
132  float z;
133  float fv;
134  };
135 
136  C2DBounds m_size;
137  C3DFVector m_voxel_size;
138  std::vector<int> m_k;
139  std::vector< std::vector<SParabola> > m_zdt;
140 
141 };
142 
150 inline std::ostream& operator << (std::ostream& os, const C2DStackDistanceTransform::DistanceFromPoint& v)
151 {
152  os << "[" << v.point << ":" << v.distance << "]";
153  return os;
154 }
155 
158 {
159  return (lhs.point == rhs.point) && (lhs.distance == rhs.distance);
160 }
161 
162 
165 
168 
170 typedef C2DStackDistanceTransformIOPluginHandler::Instance::DataKey C2DStackDistanceTransformIODataKey;
171 
173 
174 #endif
A distance transform that stores distances to a 3D binary mask given as slices.
the singleton that a plug-in handler really is
Definition: handler.hh:157
DistanceFromPoint(C3DBounds _point, float _distance)
The templatex basis class of all IO plug-ins.
Definition: ioplugin.hh:57
class EXPORT_CORE CMeans private
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
#define EXPORT_3D
Definition: defines3d.hh:44
bool operator==(const C2DStackDistanceTransform::DistanceFromPoint &lhs, const C2DStackDistanceTransform::DistanceFromPoint &rhs)
std::ostream & operator<<(std::ostream &os, const C2DStackDistanceTransform::DistanceFromPoint &v)
THandlerSingleton< TIOPluginHandler< C2DStackDistanceTransformIO > > C2DStackDistanceTransformIOPluginHandler
Plug-in handler for the transformation IO plug-ins.
helper class to derive from for data that can be loaded and stored to a disk.
Definition: iodata.hh:36
static const char *const data_descr
search path component for the plugin handling
C2DStackDistanceTransformIOPluginHandler::Instance::DataKey C2DStackDistanceTransformIODataKey
data key type for temporary storage of 3D transformations
TIOPlugin< C2DStackDistanceTransform > C2DStackDistanceTransformIO
Base class for the generic IO of transformations.
This is the base class for 2D images that can hold generic pixel data.
Definition: 2d/image.hh:47
static const char *const type_descr
search path component for the plugin handling
C2DStackDistanceTransform type
helper type for IO plugin handling
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36