v2.0.0
Loading...
Searching...
No Matches
colormap.cpp
Go to the documentation of this file.
1//=============================================================================================================
15
16//=============================================================================================================
17// INCLUDES
18//=============================================================================================================
19
20#include "colormap.h"
21#include <math.h>
22
23//=============================================================================================================
24// USED NAMESPACES
25//=============================================================================================================
26
27using namespace DISPLIB;
28
29//=============================================================================================================
30// DEFINE MEMBER METHODS
31//=============================================================================================================
32
36
37//=============================================================================================================
38
42
43//=============================================================================================================
44
45double ColorMap::linearSlope(double x, double m, double n)
46{
47 //f = m*x + n
48 return m*x + n;
49}
50
51//=============================================================================================================
52
53int ColorMap::jetR(double x)
54{
55 //Describe the red fuzzy set
56 if(x < 0.375)
57 return 0;
58 else if(x >= 0.375 && x < 0.625)
59 return (int)floor(linearSlope(x, 4, -1.5)*255);
60 else if(x >= 0.625 && x < 0.875)
61 return (int)floor(1.0*255);
62 else if(x >= 0.875)
63 return (int)floor(linearSlope(x, -4, 4.5)*255);
64 else
65 return 0;
66}
67
68//=============================================================================================================
69
70int ColorMap::jetG(double x)
71{
72 //Describe the green fuzzy set
73 if(x < 0.125)
74 return 0;
75 else if(x >= 0.125 && x < 0.375)
76 return (int)floor(linearSlope(x, 4, -0.5)*255);
77 else if(x >= 0.375 && x < 0.625)
78 return (int)floor(1.0*255);
79 else if(x >= 0.625 && x < 0.875)
80 return (int)floor(linearSlope(x, -4, 3.5)*255);
81 else
82 return 0;
83}
84
85//=============================================================================================================
86
87int ColorMap::jetB(double x)
88{
89 //Describe the blue fuzzy set
90 if(x < 0.125)
91 return (int)floor(linearSlope(x, 4, 0.5)*255);
92 else if(x >= 0.125 && x < 0.375)
93 return (int)floor(1.0*255);
94 else if(x >= 0.375 && x < 0.625)
95 return (int)floor(linearSlope(x, -4, 2.5)*255);
96 else
97 return 0;
98}
99
100//=============================================================================================================
101
102int ColorMap::hotR(double x)
103{
104 //Describe the red fuzzy set
105 if(x < 0.375)
106 return (int)floor(linearSlope(x, 2.5621, 0.0392)*255);
107 else
108 return (int)floor(1.0*255);
109}
110
111//=============================================================================================================
112
113int ColorMap::hotG(double x)
114{
115 //Describe the green fuzzy set
116 if(x < 0.375)
117 return 0;
118 else if(x >= 0.375 && x < 0.75)
119 return (int)floor(linearSlope(x, 2.6667, -1.0)*255);
120 else
121 return (int)floor(1.0*255);
122}
123
124//=============================================================================================================
125
126int ColorMap::hotB(double x)
127{
128 //Describe the blue fuzzy set
129 if(x < 0.75)
130 return 0;
131 else
132 return (int)floor(linearSlope(x,4,-3)*255);
133}
134
135//=============================================================================================================
136
138{
139 //Describe the red fuzzy set
140 if(x < 0.2188)
141 return 0;
142 else if(x < 0.5781)
143 return (int)floor(linearSlope(x, 2.7832, -0.6090)*255);
144 else
145 return (int)floor(1.0*255);
146}
147
148//=============================================================================================================
149
151{
152 //Describe the green fuzzy set
153 if(x < 0.5781)
154 return 0;
155 else if(x >= 0.5781 && x < 0.8125)
156 return (int)floor(linearSlope(x, 4.2662, -2.4663)*255);
157 else
158 return (int)floor(1.0*255);
159}
160
161//=============================================================================================================
162
164{
165 //Describe the blue fuzzy set
166 if(x < 0.8125)
167 return 0;
168 else
169 return (int)floor(linearSlope(x,5.3333,-4.3333)*255);
170}
171
172//=============================================================================================================
173
175{
176 //Describe the red fuzzy set
177 if(x < 0.5625)
178 return 0;
179 else if(x < 0.8438)
180 return (int)floor(linearSlope(x, 3.5549, -1.9996)*255);
181 else
182 return (int)floor(1.0*255);
183}
184
185//=============================================================================================================
186
188{
189 //Describe the green fuzzy set
190 if(x < 0.8438)
191 return 0;
192 else if(x >= 0.8438 && x < 0.9531)
193 return (int)floor(linearSlope(x, 9.1491, -7.72)*255);
194 else
195 return (int)floor(1.0*255);
196}
197
198//=============================================================================================================
199
201{
202 //Describe the blue fuzzy set
203 if(x < 0.9531)
204 return 0;
205 else
206 return (int)floor(linearSlope(x,21.3220,-20.3220)*255);
207}
208
209//=============================================================================================================
210
211int ColorMap::boneR(double x)
212{
213 //Describe the red fuzzy set
214 if(x < 0.375)
215 return (int)floor(linearSlope(x, 0.8471, 0)*255);
216 else if(x >= 0.375 && x < 0.75)
217 return (int)floor(linearSlope(x, 0.8889, -0.0157)*255);
218 else
219 return (int)floor(linearSlope(x, 1.396, -0.396)*255);
220}
221
222//=============================================================================================================
223
224int ColorMap::boneG(double x)
225{
226 //Describe the green fuzzy set
227 if(x < 0.375)
228 return (int)floor(linearSlope(x, 0.8471, 0)*255);
229 else if(x >= 0.375 && x < 0.75)
230 return (int)floor(linearSlope(x, 1.2237, -0.1413)*255);
231 else
232 return (int)floor(linearSlope(x, 0.894, 0.106)*255);
233}
234
235//=============================================================================================================
236
237int ColorMap::boneB(double x)
238{
239 //Describe the blue fuzzy set
240 if(x < 0.375)
241 return (int)floor(linearSlope(x, 1.1712, 0.0039)*255);
242 else if(x >= 0.375 && x < 0.75)
243 return (int)floor(linearSlope(x, 0.8889, 0.1098)*255);
244 else
245 return (int)floor(linearSlope(x, 0.8941, 0.1059)*255);
246}
247
248//=============================================================================================================
249
250int ColorMap::rbR(double x)
251{
252 //Describe the red fuzzy set
253 if(x < 0)
254 return (int)floor(linearSlope(x, 1, 1)*255);
255 else
256 return (int)floor(1.0*255);
257}
258
259//=============================================================================================================
260
261int ColorMap::rbG(double x)
262{
263 //Describe the green fuzzy set
264 if(x < 0)
265 return (int)floor(linearSlope(x, 1, 1)*255);
266 else
267 return (int)floor(linearSlope(x, -1, 1)*255);
268}
269
270//=============================================================================================================
271
272int ColorMap::rbB(double x)
273{
274 //Describe the blue fuzzy set
275 if(x < 0)
276 return (int)floor(1.0*255);
277 else
278 return (int)floor(linearSlope(x, -1, 1)*255);
279}
280
281//=============================================================================================================
282
283int ColorMap::coolR(double x)
284{
285 //Describe the red fuzzy set
286 return (int)floor(linearSlope(x, 1, 0)*255);
287}
288
289//=============================================================================================================
290
291int ColorMap::coolG(double x)
292{
293 //Describe the green fuzzy set
294 return (int)floor(linearSlope(x, -1, 1)*255);
295}
296
297//=============================================================================================================
298
299int ColorMap::coolB(double x)
300{
301 Q_UNUSED(x)
302 //Describe the blue fuzzy set
303 return (int)floor(1.0*255);
304}
Static scalar-to-colour lookup helpers (Jet, Hot, Bone, Viridis, Cool, RedBlue, MNE) used by every pl...
2-D display widgets and visualisation helpers (charts, topography, colour maps).
static int hotG(double v)
Definition colormap.cpp:113
static int coolR(double v)
Definition colormap.cpp:283
static int hotRNeg2(double v)
Definition colormap.cpp:174
static int rbB(double v)
Definition colormap.cpp:272
static double linearSlope(double x, double m, double n)
Definition colormap.cpp:45
static int boneR(double v)
Definition colormap.cpp:211
static int hotGNeg2(double v)
Definition colormap.cpp:187
static int jetR(double v)
Definition colormap.cpp:53
static int hotBNeg2(double v)
Definition colormap.cpp:200
static int jetB(double v)
Definition colormap.cpp:87
static int rbG(double v)
Definition colormap.cpp:261
static int jetG(double v)
Definition colormap.cpp:70
static int rbR(double v)
Definition colormap.cpp:250
static int hotBNeg1(double v)
Definition colormap.cpp:163
static int hotGNeg1(double v)
Definition colormap.cpp:150
static int coolB(double v)
Definition colormap.cpp:299
static int hotRNeg1(double v)
Definition colormap.cpp:137
static int boneB(double v)
Definition colormap.cpp:237
static int hotR(double v)
Definition colormap.cpp:102
static int hotB(double v)
Definition colormap.cpp:126
static int boneG(double v)
Definition colormap.cpp:224
static int coolG(double v)
Definition colormap.cpp:291