My Project
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 {
49 public:
52 
54  static const char *const data_descr;
55 
57  static const char *const type_descr;
58 
59 
64 
70  DistanceFromPoint(C3DBounds _point, float _distance):
71  point(_point),
72  distance(_distance)
73  {};
74  C3DBounds point;
75  float distance;
76  };
77 
78 
79  C2DStackDistanceTransform() = default;
80 
84  C2DStackDistanceTransform(const C2DStackDistanceTransform& /*other*/) = default;
85 
89  C2DStackDistanceTransform *clone() const __attribute__((warn_unused_result));
90 
97  C2DStackDistanceTransform(const C2DImage& slice, const C3DFVector& voxel_size = C3DFVector::_1);
98 
105  void read( const C2DImage& slice, int q);
106 
107 
114  std::vector<DistanceFromPoint> get_slice(size_t s, const C2DImage& image) const;
115 
121  bool save(const std::string& filename);
122 
123 private:
124 
125  float d(float fq, float q, float fv, float v)const;
126 
127  void dt1d(std::vector<float>& f, float scale)const;
128  void dt2d(C2DFImage& image)const;
129 
130  struct SParabola {
131  int k;
132  int v;
133  float z;
134  float fv;
135  };
136 
137  C2DBounds m_size;
138  C3DFVector m_voxel_size;
139  std::vector<int> m_k;
140  std::vector< std::vector<SParabola>> m_zdt;
141 
142 };
143 
151 inline std::ostream& operator << (std::ostream& os, const C2DStackDistanceTransform::DistanceFromPoint& v)
152 {
153  os << "[" << v.point << ":" << v.distance << "]";
154  return os;
155 }
156 
159 {
160  return (lhs.point == rhs.point) && (lhs.distance == rhs.distance);
161 }
162 
163 
166 
169 
171 typedef C2DStackDistanceTransformIOPluginHandler::Instance::DataKey C2DStackDistanceTransformIODataKey;
172 
174 
175 #endif
C2DStackDistanceTransform::DistanceFromPoint::distance
float distance
Definition: stackdisttrans.hh:75
C2DStackDistanceTransform::data_descr
static const char *const data_descr
search path component for the plugin handling
Definition: stackdisttrans.hh:54
C2DStackDistanceTransformIODataKey
C2DStackDistanceTransformIOPluginHandler::Instance::DataKey C2DStackDistanceTransformIODataKey
data key type for temporary storage of 3D transformations
Definition: stackdisttrans.hh:171
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
C2DStackDistanceTransform::DistanceFromPoint::DistanceFromPoint
DistanceFromPoint(C3DBounds _point, float _distance)
Definition: stackdisttrans.hh:70
private
class EXPORT_CORE CMeans private
C2DImage
This is the base class for 2D images that can hold generic pixel data.
Definition: 2d/image.hh:47
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36
THandlerSingleton
the singleton that a plug-in handler really is
Definition: handler.hh:158
T2DVector< unsigned int >
iohandler.hh
TIOPlugin
The templatex basis class of all IO plug-ins.
Definition: ioplugin.hh:57
C2DStackDistanceTransformIO
TIOPlugin< C2DStackDistanceTransform > C2DStackDistanceTransformIO
Base class for the generic IO of transformations.
Definition: stackdisttrans.hh:165
defines3d.hh
C2DStackDistanceTransform::DistanceFromPoint::point
C3DBounds point
Definition: stackdisttrans.hh:73
EXPORT_3D
#define EXPORT_3D
Definition: defines3d.hh:45
CIOData
helper class to derive from for data that can be loaded and stored to a disk.
Definition: iodata.hh:36
C2DStackDistanceTransform::type_descr
static const char *const type_descr
search path component for the plugin handling
Definition: stackdisttrans.hh:57
operator==
bool operator==(const C2DStackDistanceTransform::DistanceFromPoint &lhs, const C2DStackDistanceTransform::DistanceFromPoint &rhs)
Definition: stackdisttrans.hh:157
operator<<
std::ostream & operator<<(std::ostream &os, const C2DStackDistanceTransform::DistanceFromPoint &v)
Definition: stackdisttrans.hh:151
std
Definition: gsl_iterator.hh:323
T2DImage< float >
image.hh
C2DStackDistanceTransform
A distance transform that stores distances to a 3D binary mask given as slices.
Definition: stackdisttrans.hh:47
C2DStackDistanceTransform::type
C2DStackDistanceTransform type
helper type for IO plugin handling
Definition: stackdisttrans.hh:51
T3DVector< unsigned int >
ioplugin.hh
vector.hh
C2DStackDistanceTransform::DistanceFromPoint
Definition: stackdisttrans.hh:63
C2DStackDistanceTransformIOPluginHandler
THandlerSingleton< TIOPluginHandler< C2DStackDistanceTransformIO > > C2DStackDistanceTransformIOPluginHandler
Plug-in handler for the transformation IO plug-ins.
Definition: stackdisttrans.hh:168