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