Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
mia
3d
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-2013 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
31
NS_MIA_BEGIN
32
47
class
EXPORT_3D
C2DStackDistanceTransform
:
public
CIOData
{
48
public
:
50
typedef
C2DStackDistanceTransform
type
;
51
53
static
const
char
*
const
data_descr
;
54
56
static
const
char
*
const
type_descr
;
57
58
62
struct
DistanceFromPoint
{
63
69
DistanceFromPoint
(
C3DBounds
_point,
float
_distance):
70
point(_point),
71
distance(_distance)
72
{};
73
C3DBounds
point;
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
156
inline
bool
operator ==
(
const
C2DStackDistanceTransform::DistanceFromPoint
& lhs,
157
const
C2DStackDistanceTransform::DistanceFromPoint
& rhs)
158
{
159
return
(lhs.
point
== rhs.
point
) && (lhs.
distance
== rhs.
distance
);
160
}
161
162
164
typedef
TIOPlugin<C2DStackDistanceTransform>
C2DStackDistanceTransformIO
;
165
167
typedef
THandlerSingleton< TIOPluginHandler<C2DStackDistanceTransformIO>
>
C2DStackDistanceTransformIOPluginHandler
;
168
170
typedef
C2DStackDistanceTransformIOPluginHandler::Instance::DataKey
C2DStackDistanceTransformIODataKey
;
171
172
NS_MIA_END
173
174
#endif
Generated on Tue Oct 15 2013 13:56:37 by
1.8.4