ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/falsecolor.c
(Generate patch)

Comparing ray/src/common/falsecolor.c (file contents):
Revision 3.2 by greg, Tue Nov 15 06:52:38 2005 UTC vs.
Revision 3.4 by greg, Wed Nov 16 08:30:15 2005 UTC

# Line 49 | Line 49 | fcFixedLinear(FCstruct *fcs, double Lwmax)
49                  return(TM_E_NOMEM);
50          mult = 255.999/tmLuminance(fcs->mbrmax);
51          for (i = fcs->mbrmin; i <= fcs->mbrmax; i++)
52 <                fcs->lumap[i] = (int)(mult * tmLuminance(i));
52 >                fcs->lumap[i - fcs->mbrmin] = (int)(mult * tmLuminance(i));
53          returnOK;
54   }
55  
# Line 65 | Line 65 | fcFixedLog(FCstruct *fcs, double Lwmin, double Lwmax)
65                  free((void *)fcs->lumap);
66          fcs->mbrmin = tmCvLuminance(Lwmin);
67          fcs->mbrmax = tmCvLuminance(Lwmax);
68 +        if (fcs->mbrmin >= fcs->mbrmax) {
69 +                fcs->lumap = NULL;
70 +                return(TM_E_ILLEGAL);
71 +        }
72          fcs->lumap = (BYTE *)malloc(sizeof(BYTE)*(fcs->mbrmax - fcs->mbrmin + 1));
73          if (fcs->lumap == NULL)
74                  return(TM_E_NOMEM);
75 <        for (i = fcs->mbrmin; i <= fcs->mbrmax; i++)
76 <                fcs->lumap[i] = 256*(i - fcs->mbrmin) /
73 <                                        (fcs->mbrmax - fcs->mbrmin + 1);
75 >        for (i = fcs->mbrmax - fcs->mbrmin; i >= 0; i--)
76 >                fcs->lumap[i] = 256L * i / (fcs->mbrmax - fcs->mbrmin + 1);
77          returnOK;
78   }
79  
80   /* Compute linear false color map */
81   int
82 < fcLinearMapping(FCstruct *fcs, TMstruct *tms, int pctile)
82 > fcLinearMapping(FCstruct *fcs, TMstruct *tms, double pctile)
83   {
84 <        int             i;
84 >        int             i, histlen;
85          int32           histot, cnt;
86 <        TMbright        wbrmin, wbrmax;
86 >        int             brt0;
87  
88          if ((fcs == NULL) | (tms == NULL) || (tms->histo == NULL) |
89 <                        (0 > pctile) | (pctile >= 100))
89 >                        (0 > pctile) | (pctile >= 50))
90                  return(TM_E_ILLEGAL);
91 +        i = (tms->hbrmin-MINBRT)/HISTEP;
92 +        brt0 = MINBRT + HISTEP/2 + i*HISTEP;
93 +        histlen = (tms->hbrmax-MINBRT)/HISTEP + 1 - i;
94          histot = 0;
95 <        for (i = tms->hbrmax - tms->hbrmin; i >= 0; )
96 <                histot += tms->histo[i--];
95 >        for (i = histlen; i--; )
96 >                histot += tms->histo[i];
97          cnt = histot * pctile / 100;
98 <        for (i = tms->hbrmax - tms->hbrmin; i >= 0; i--)
98 >        for (i = histlen; i--; )
99                  if ((cnt -= tms->histo[i]) < 0)
100                          break;
101 <        if (i < 0)
101 >        if (i <= 0)
102                  return(TM_E_TMFAIL);
103 <        return(fcFixedLinear(fcs, tmLuminance(tms->hbrmin + i)));
103 >        return(fcFixedLinear(fcs, tmLuminance(brt0 + i*HISTEP)));
104   }
105  
106   /* Compute logarithmic false color map */
107   int
108 < fcLogMapping(FCstruct *fcs, TMstruct *tms, int pctile)
108 > fcLogMapping(FCstruct *fcs, TMstruct *tms, double pctile)
109   {
110 <        int             i;
110 >        int             i, histlen;
111          int32           histot, cnt;
112 <        TMbright        wbrmin, wbrmax;
112 >        int             brt0, wbrmin, wbrmax;
113  
114          if ((fcs == NULL) | (tms == NULL) || (tms->histo == NULL) |
115 <                        (0 > pctile) | (pctile >= 100))
115 >                        (0 > pctile) | (pctile >= 50))
116                  return(TM_E_ILLEGAL);
117 +        i = (tms->hbrmin-MINBRT)/HISTEP;
118 +        brt0 = MINBRT + HISTEP/2 + i*HISTEP;
119 +        histlen = (tms->hbrmax-MINBRT)/HISTEP + 1 - i;
120          histot = 0;
121 <        for (i = tms->hbrmax - tms->hbrmin; i >= 0; )
122 <                histot += tms->histo[i--];
121 >        for (i = histlen; i--; )
122 >                histot += tms->histo[i];
123          cnt = histot * pctile / 100;
124 <        for (i = 0; i <= tms->hbrmax - tms->hbrmin; i++)
124 >        for (i = 0; i < histlen; i++)
125                  if ((cnt -= tms->histo[i]) < 0)
126                          break;
127 <        if (i >= tms->hbrmax - tms->hbrmin)
127 >        if (i >= histlen)
128                  return(TM_E_TMFAIL);
129 <        wbrmin = tms->hbrmin + i;
129 >        wbrmin = brt0 + i*HISTEP;
130          cnt = histot * pctile / 100;
131 <        for (i = tms->hbrmax - tms->hbrmin; i >= 0; i--)
131 >        for (i = histlen; i--; )
132                  if ((cnt -= tms->histo[i]) < 0)
133                          break;
134 <        if (i < 0)
134 >        wbrmax = brt0 + i*HISTEP;
135 >        if (wbrmax <= wbrmin)
136                  return(TM_E_TMFAIL);
127        wbrmax = tms->hbrmin + i;
137          return(fcFixedLog(fcs, tmLuminance(wbrmin), tmLuminance(wbrmax)));
138   }
139  
# Line 199 | Line 208 | fcDone(FCstruct *fcs)
208   }
209  
210   BYTE    fcDefaultScale[256][3] = {      /* default false color scale */
211 <        48,0,68, 45,0,70, 42,0,72, 39,0,74, 36,0,76, 33,0,78, 30,0,81,
212 <        27,0,83, 24,0,85, 21,0,87, 18,0,89, 15,0,91, 13,0,94, 12,0,96,
213 <        11,0,99, 9,0,101, 8,0,104, 7,0,106, 6,0,109, 5,0,111, 4,0,114,
214 <         2,0,116, 1,0,119, 0,0,121, 0,0,122, 0,1,123, 0,1,124, 0,2,125,
215 <         0,2,125, 0,3,126, 0,4,127, 0,4,128, 0,5,129, 0,5,129, 0,6,130,
216 <         0,7,131, 0,9,131, 0,11,132, 0,13,133, 0,16,133, 0,18,134,
217 <         0,20,134, 0,22,135, 0,24,135, 0,26,136, 0,29,136, 0,31,137,
218 <         0,34,137, 0,37,136, 0,41,136, 0,45,135, 0,48,135, 0,52,135,
219 <         0,55,134, 0,59,134, 0,62,134, 0,66,133, 0,69,133, 0,73,132,
220 <         0,76,130, 0,79,127, 0,82,125, 0,85,123, 0,88,120, 0,91,118,
221 <         0,94,115, 0,97,113, 0,101,110, 0,104,108, 0,107,106, 0,109,102,
222 <         0,110,97, 0,111,91, 0,112,86, 0,113,81, 0,115,76, 0,116,71,
223 <         0,117,65, 0,118,60, 0,119,55, 0,120,50, 0,122,45, 0,121,42,
224 <         1,120,39, 1,119,36, 1,119,34, 1,118,31, 2,117,28, 2,116,26,
225 <         2,115,23, 2,115,20, 3,114,18, 3,113,15, 3,112,13, 4,110,13,
226 <         5,108,13, 6,106,13, 7,104,12, 9,102,12, 10,100,12, 11,98,12,
227 <        12,97,12, 13,95,12, 14,93,11, 15,91,11, 17,89,12, 19,86,12,
228 <        22,83,12, 24,81,13, 26,78,13, 29,76,14, 31,73,14, 34,70,15,
229 <        36,68,15, 39,65,16, 41,63,16, 44,60,17, 46,58,17, 49,56,17,
230 <        51,54,17, 54,52,17, 57,50,17, 59,48,17, 62,45,17, 64,43,17,
231 <        67,41,17, 70,39,17, 72,37,17, 74,35,17, 75,34,16, 76,33,16,
232 <        77,32,16, 79,31,15, 80,30,15, 81,29,14, 82,28,14, 83,26,13,
233 <        84,25,13, 85,24,13, 87,23,12, 87,22,12, 88,21,11, 89,20,11,
234 <        90,19,10, 91,18,10, 92,17,9, 93,16,9, 94,15,8, 95,14,8,
235 <        95,13,7, 96,12,7, 97,11,7, 98,11,6, 99,10,6, 99,9,5, 100,9,5,
236 <       101,8,5, 102,8,4, 102,7,4, 103,6,4, 104,6,3, 104,5,3, 105,4,2,
237 <       106,4,2, 107,4,2, 107,3,2, 108,3,2, 109,3,2, 109,2,1, 110,2,1,
238 <       111,2,1, 112,1,1, 112,1,1, 113,1,0, 114,1,0, 115,0,0, 116,0,0,
239 <       117,0,0, 118,0,0, 119,0,0, 121,0,0, 122,0,0, 123,0,0, 124,0,0,
240 <       125,0,0, 126,0,0, 128,0,0, 131,0,0, 134,0,0, 137,0,0, 140,0,0,
241 <       144,0,0, 147,0,0, 150,0,0, 153,0,0, 156,0,0, 159,0,0, 162,0,0,
242 <       165,0,0, 168,0,0, 171,0,0, 174,0,0, 177,0,0, 180,1,0, 183,1,0,
243 <       186,1,0, 189,1,0, 192,1,0, 195,2,0, 198,2,0, 201,5,0, 204,7,0,
244 <       207,9,0, 210,11,0, 213,13,0, 216,15,0, 219,17,0, 222,19,0,
245 <       225,21,0, 228,23,0, 230,25,0, 233,29,0, 235,34,0, 237,39,0,
246 <       239,43,0, 241,48,0, 243,52,0, 245,57,0, 247,61,0, 250,66,0,
247 <       252,71,0, 254,75,0, 255,80,0, 255,88,0, 255,95,1, 255,103,1,
248 <       255,110,1, 255,117,1, 255,125,1, 255,132,2, 255,139,2, 255,147,2,
249 <       255,154,2, 255,162,2, 255,169,3, 255,176,3, 255,183,3, 254,190,4,
250 <       254,198,4, 254,205,4, 254,212,4, 253,219,5, 253,226,5, 253,234,5,
251 <       252,241,6, 252,248,6
211 >       119,10,140,
212 >       116,10,142,
213 >       112,10,144,
214 >       109,9,146,
215 >       105,9,148,
216 >       101,8,150,
217 >        97,7,151,
218 >        92,7,153,
219 >        88,6,155,
220 >        83,5,157,
221 >        77,4,158,
222 >        72,2,160,
223 >        67,2,162,
224 >        64,4,164,
225 >        61,5,166,
226 >        58,6,168,
227 >        55,6,170,
228 >        51,7,171,
229 >        47,8,173,
230 >        43,8,175,
231 >        38,9,177,
232 >        33,9,179,
233 >        25,10,180,
234 >        14,10,182,
235 >        10,17,183,
236 >        10,22,183,
237 >         9,27,184,
238 >         9,30,184,
239 >         8,33,185,
240 >         8,36,185,
241 >         7,39,186,
242 >         6,41,187,
243 >         5,43,187,
244 >         4,45,188,
245 >         3,47,188,
246 >         0,50,189,
247 >         0,57,189,
248 >         0,62,189,
249 >         0,67,190,
250 >         0,72,190,
251 >         0,77,190,
252 >         0,81,191,
253 >         0,84,191,
254 >         1,88,191,
255 >         1,92,192,
256 >         1,95,192,
257 >         1,98,192,
258 >         2,102,192,
259 >         3,107,192,
260 >         3,112,192,
261 >         4,116,191,
262 >         5,120,191,
263 >         5,124,191,
264 >         5,128,191,
265 >         6,131,191,
266 >         6,135,190,
267 >         7,138,190,
268 >         7,141,190,
269 >         7,145,189,
270 >         8,147,188,
271 >         8,150,186,
272 >         9,153,185,
273 >         9,155,183,
274 >        10,158,181,
275 >        10,160,180,
276 >        11,163,178,
277 >        11,165,176,
278 >        11,167,175,
279 >        12,170,173,
280 >        12,172,171,
281 >        13,173,168,
282 >        13,174,164,
283 >        14,175,160,
284 >        14,176,156,
285 >        15,177,152,
286 >        15,178,147,
287 >        16,178,143,
288 >        16,179,138,
289 >        17,180,133,
290 >        17,181,127,
291 >        18,182,122,
292 >        18,182,116,
293 >        20,182,112,
294 >        22,181,109,
295 >        24,181,105,
296 >        26,180,102,
297 >        27,180,98,
298 >        29,179,94,
299 >        30,179,90,
300 >        32,178,86,
301 >        33,177,81,
302 >        34,177,77,
303 >        35,176,71,
304 >        37,176,67,
305 >        42,174,67,
306 >        46,173,66,
307 >        49,171,66,
308 >        52,170,65,
309 >        55,169,65,
310 >        58,167,65,
311 >        61,166,64,
312 >        64,164,64,
313 >        66,163,63,
314 >        68,161,63,
315 >        71,160,63,
316 >        75,158,63,
317 >        79,156,64,
318 >        84,154,65,
319 >        88,151,66,
320 >        92,149,68,
321 >        95,147,69,
322 >        99,145,70,
323 >       102,142,71,
324 >       105,140,71,
325 >       109,137,72,
326 >       112,135,73,
327 >       115,132,74,
328 >       118,130,74,
329 >       121,128,74,
330 >       123,126,74,
331 >       126,124,74,
332 >       129,121,75,
333 >       132,119,75,
334 >       134,117,75,
335 >       137,114,75,
336 >       139,112,75,
337 >       142,109,75,
338 >       144,106,75,
339 >       146,104,75,
340 >       147,103,74,
341 >       148,101,73,
342 >       149,100,72,
343 >       150,98,71,
344 >       151,96,70,
345 >       152,95,70,
346 >       152,93,69,
347 >       153,91,68,
348 >       154,90,67,
349 >       155,88,66,
350 >       156,86,65,
351 >       157,84,64,
352 >       158,83,63,
353 >       158,81,62,
354 >       159,79,60,
355 >       160,77,59,
356 >       161,75,58,
357 >       161,73,57,
358 >       162,71,55,
359 >       163,69,54,
360 >       163,67,52,
361 >       164,65,51,
362 >       165,63,49,
363 >       165,61,48,
364 >       166,60,47,
365 >       166,58,46,
366 >       167,56,44,
367 >       167,55,43,
368 >       168,53,42,
369 >       169,51,40,
370 >       169,49,39,
371 >       170,46,37,
372 >       170,44,35,
373 >       171,42,33,
374 >       171,40,32,
375 >       172,39,31,
376 >       172,37,30,
377 >       173,36,29,
378 >       173,34,28,
379 >       174,33,27,
380 >       174,31,25,
381 >       175,29,24,
382 >       175,27,22,
383 >       176,25,21,
384 >       176,23,19,
385 >       177,21,17,
386 >       178,20,16,
387 >       179,19,16,
388 >       179,18,15,
389 >       180,17,14,
390 >       181,16,13,
391 >       182,15,13,
392 >       182,13,12,
393 >       183,12,11,
394 >       184,10,9,
395 >       185,8,8,
396 >       185,5,6,
397 >       187,3,5,
398 >       189,3,5,
399 >       191,3,5,
400 >       193,3,6,
401 >       195,3,6,
402 >       197,2,6,
403 >       198,2,6,
404 >       200,2,6,
405 >       202,2,6,
406 >       204,1,6,
407 >       206,1,6,
408 >       208,0,6,
409 >       209,9,7,
410 >       211,13,7,
411 >       213,15,8,
412 >       214,18,8,
413 >       216,20,9,
414 >       218,21,9,
415 >       219,23,9,
416 >       221,24,10,
417 >       223,26,10,
418 >       224,27,10,
419 >       226,28,11,
420 >       228,33,11,
421 >       229,43,11,
422 >       231,50,11,
423 >       232,56,11,
424 >       234,61,11,
425 >       235,66,11,
426 >       237,71,11,
427 >       238,75,11,
428 >       239,79,11,
429 >       241,83,11,
430 >       242,86,11,
431 >       244,90,11,
432 >       245,96,11,
433 >       246,102,12,
434 >       247,108,12,
435 >       248,114,13,
436 >       249,119,13,
437 >       250,124,13,
438 >       251,129,14,
439 >       252,134,14,
440 >       253,138,15,
441 >       254,143,15,
442 >       255,147,15,
443 >       255,151,16,
444 >       255,157,18,
445 >       255,163,20,
446 >       255,169,22,
447 >       255,174,24,
448 >       255,179,25,
449 >       255,184,26,
450 >       255,189,28,
451 >       255,194,29,
452 >       255,199,30,
453 >       255,203,31,
454 >       255,207,32,
455 >       255,212,34,
456 >       255,216,35,
457 >       255,220,37,
458 >       255,224,38,
459 >       255,227,40,
460 >       255,231,41,
461 >       255,235,42,
462 >       254,238,43,
463 >       254,242,44,
464 >       254,245,46,
465 >       254,249,47,
466 >       254,252,48,
467   };

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines