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