forked from frankyeh/TIPL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtipl.hpp
More file actions
162 lines (142 loc) · 4.14 KB
/
Copy pathtipl.hpp
File metadata and controls
162 lines (142 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
Copyright (c) 2010-2026 Fang-Cheng Yeh
All rights reserved.
The TIPL library is dual-licensed. You may use it under one of the following licenses:
1. GNU General Public License v3.0 (GPLv3)
https://www.gnu.org/licenses/gpl-3.0.en.html
2. A proprietary license granted by the copyright holder, which permits closed-source use.
*/
#include "def.hpp"
#include "cmd.hpp"
#include "mt.hpp"
#include "prog.hpp"
#include "po.hpp"
#include "utility/basic_image.hpp"
#include "utility/pixel_index.hpp"
#include "utility/rgb_image.hpp"
#include "numerical/transformation.hpp"
#include "numerical/index_algorithm.hpp"
#include "numerical/interpolation.hpp"
#include "numerical/window.hpp"
#include "numerical/basic_op.hpp"
#include "numerical/numerical.hpp"
#include "numerical/resampling.hpp"
#include "numerical/fft.hpp"
#include "numerical/optimization.hpp"
#include "numerical/statistics.hpp"
#include "numerical/dif.hpp"
#include "numerical/morphology.hpp"
#include "numerical/otsu.hpp"
#include "io/gz_stream.hpp"
#include "io/nrrd.hpp"
#include "io/dicom.hpp"
#include "io/nifti.hpp"
#include "io/bitmap.hpp"
#include "io/mat.hpp"
#include "io/2dseq.hpp"
#include "io/avi.hpp"
#include "filter/filter_model.hpp"
#include "filter/anisotropic_diffusion.hpp"
#include "filter/gaussian.hpp"
#include "filter/mean.hpp"
#include "filter/sobel.hpp"
#include "filter/canny_edge.hpp"
#include "filter/gradient_magnitude.hpp"
#include "filter/laplacian.hpp"
#include "reg/linear.hpp"
#include "reg/cdm.hpp"
#include "reg/bfnorm.hpp"
#include "reg/mm_reg.hpp"
#include "ml/utility.hpp"
#include "ml/nb.hpp"
#include "ml/lg.hpp"
#include "ml/non_parametric.hpp"
#include "ml/ada_boost.hpp"
#include "ml/decision_tree.hpp"
#include "ml/k_means.hpp"
#include "ml/em.hpp"
#include "ml/hmc.hpp"
#include "ml/cnn.hpp"
#ifndef __CUDACC__
#include "ml/cnn3d_detail.hpp"
#include "ml/cnn3d.hpp"
#include "ml/unet3d.hpp"
#endif
#include "vis/march_cube.hpp"
#include "vis/color_map.hpp"
#include "vis/qt_ext.hpp"
#ifdef __CUDACC__
#include "cu.hpp"
#endif
#ifdef USING_XEUS_CLING
// XEUS interface
#include "xtl/xbase64.hpp"
#include "nlohmann/json.hpp"
namespace nl = nlohmann;
namespace tipl
{
template <typename pixel_type,typename storage_type>
nl::json mime_bundle_repr(const tipl::image<2,pixel_type,storage_type>& I)
{
tipl::io::bitmap bmp;
bmp << I;
std::stringstream out;
bmp.save_to_stream(out);
auto bundle = nl::json::object();
bundle["image/png"] = xtl::base64encode(out.str());
return bundle;
}
template <typename pixel_type,typename storage_type>
nl::json mime_bundle_repr(const tipl::image<3,pixel_type,storage_type>& I)
{
return mime_bundle_repr(I.slice_at(I.depth()/2));
}
template <int dim>
nl::json mime_bundle_repr(const tipl::shape<dim>& d)
{
std::stringstream out;
out << d;
auto bundle = nl::json::object();
bundle["text/plain"] = out.str();
return bundle;
}
template <int r,int c,typename value_type>
nl::json mime_bundle_repr(const tipl::matrix<r,c,value_type>& m)
{
std::stringstream out;
out << m;
auto bundle = nl::json::object();
bundle["text/plain"] = out.str();
return bundle;
}
template <int dim,typename value_type>
nl::json mime_bundle_repr(const tipl::vector<dim,value_type>& v)
{
std::stringstream out;
out << v;
auto bundle = nl::json::object();
bundle["text/plain"] = out.str();
return bundle;
}
template <typename value_type>
nl::json mime_bundle_repr(const std::vector<value_type>& vec)
{
std::stringstream out;
for(const auto& i : vec)
out << i << std::endl;
auto bundle = nl::json::object();
bundle["text/plain"] = out.str();
return bundle;
}
namespace io{
nl::json mime_bundle_repr(const tipl::io::nifti& nii)
{
std::stringstream out;
out << nii;
auto bundle = nl::json::object();
bundle["text/plain"] = out.str();
return bundle;
}
}
}
#endif//INCLUDE_NLOHMANN_JSON_HPP_