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{
49public:
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 {};
75 float distance;
76 };
77
78
80
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
123private:
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
151inline 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
171typedef C2DStackDistanceTransformIOPluginHandler::Instance::DataKey C2DStackDistanceTransformIODataKey;
172
174
175#endif
This is the base class for 2D images that can hold generic pixel data.
Definition 2d/image.hh:48
A distance transform that stores distances to a 3D binary mask given as slices.
C2DStackDistanceTransform(const C2DStackDistanceTransform &)=default
C2DStackDistanceTransform type
helper type for IO plugin handling
static const char *const type_descr
search path component for the plugin handling
C2DStackDistanceTransform()=default
static const char *const data_descr
search path component for the plugin handling
C2DStackDistanceTransform * clone() const __attribute__((warn_unused_result))
helper class to derive from for data that can be loaded and stored to a disk.
Definition iodata.hh:37
the singleton that a plug-in handler really is
Definition handler.hh:159
The templatex basis class of all IO plug-ins.
Definition ioplugin.hh:58
#define EXPORT_3D
Definition defines3d.hh:45
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
std::ostream & operator<<(std::ostream &os, const C2DStackDistanceTransform::DistanceFromPoint &v)
bool operator==(const C2DStackDistanceTransform::DistanceFromPoint &lhs, const C2DStackDistanceTransform::DistanceFromPoint &rhs)
THandlerSingleton< TIOPluginHandler< C2DStackDistanceTransformIO > > C2DStackDistanceTransformIOPluginHandler
Plug-in handler for the transformation IO plug-ins.
TIOPlugin< C2DStackDistanceTransform > C2DStackDistanceTransformIO
Base class for the generic IO of transformations.
C2DStackDistanceTransformIOPluginHandler::Instance::DataKey C2DStackDistanceTransformIODataKey
data key type for temporary storage of 3D transformations
DistanceFromPoint(C3DBounds _point, float _distance)