9 |
|
* Externals declared in tonemap.h |
10 |
|
*/ |
11 |
|
|
12 |
< |
/* ==================================================================== |
13 |
< |
* The Radiance Software License, Version 1.0 |
14 |
< |
* |
15 |
< |
* Copyright (c) 1990 - 2002 The Regents of the University of California, |
16 |
< |
* through Lawrence Berkeley National Laboratory. All rights reserved. |
17 |
< |
* |
18 |
< |
* Redistribution and use in source and binary forms, with or without |
19 |
< |
* modification, are permitted provided that the following conditions |
20 |
< |
* are met: |
21 |
< |
* |
22 |
< |
* 1. Redistributions of source code must retain the above copyright |
23 |
< |
* notice, this list of conditions and the following disclaimer. |
24 |
< |
* |
25 |
< |
* 2. Redistributions in binary form must reproduce the above copyright |
26 |
< |
* notice, this list of conditions and the following disclaimer in |
27 |
< |
* the documentation and/or other materials provided with the |
28 |
< |
* distribution. |
29 |
< |
* |
30 |
< |
* 3. The end-user documentation included with the redistribution, |
31 |
< |
* if any, must include the following acknowledgment: |
32 |
< |
* "This product includes Radiance software |
33 |
< |
* (http://radsite.lbl.gov/) |
34 |
< |
* developed by the Lawrence Berkeley National Laboratory |
35 |
< |
* (http://www.lbl.gov/)." |
36 |
< |
* Alternately, this acknowledgment may appear in the software itself, |
37 |
< |
* if and wherever such third-party acknowledgments normally appear. |
38 |
< |
* |
39 |
< |
* 4. The names "Radiance," "Lawrence Berkeley National Laboratory" |
40 |
< |
* and "The Regents of the University of California" must |
41 |
< |
* not be used to endorse or promote products derived from this |
42 |
< |
* software without prior written permission. For written |
43 |
< |
* permission, please contact [email protected]. |
44 |
< |
* |
45 |
< |
* 5. Products derived from this software may not be called "Radiance", |
46 |
< |
* nor may "Radiance" appear in their name, without prior written |
47 |
< |
* permission of Lawrence Berkeley National Laboratory. |
48 |
< |
* |
49 |
< |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
50 |
< |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
51 |
< |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
52 |
< |
* DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR |
53 |
< |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
54 |
< |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
55 |
< |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
56 |
< |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
57 |
< |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
58 |
< |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
59 |
< |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
60 |
< |
* SUCH DAMAGE. |
61 |
< |
* ==================================================================== |
62 |
< |
* |
63 |
< |
* This software consists of voluntary contributions made by many |
64 |
< |
* individuals on behalf of Lawrence Berkeley National Laboratory. For more |
65 |
< |
* information on Lawrence Berkeley National Laboratory, please see |
66 |
< |
* <http://www.lbl.gov/>. |
67 |
< |
*/ |
12 |
> |
#include "copyright.h" |
13 |
|
|
14 |
|
#include <stdio.h> |
15 |
|
#include <math.h> |
43 |
|
return(NULL); |
44 |
|
|
45 |
|
tmnew->flags = flags & ~TM_F_UNIMPL; |
46 |
+ |
if (tmnew->flags & TM_F_BW) |
47 |
+ |
tmnew->flags &= ~TM_F_MESOPIC; |
48 |
|
/* set monitor transform */ |
49 |
|
if (monpri == NULL || monpri == stdprims || tmnew->flags & TM_F_BW) { |
50 |
|
tmnew->monpri = stdprims; |
164 |
|
int len; |
165 |
|
{ |
166 |
|
static char funcName[] = "tmCvColors"; |
167 |
< |
static COLOR csmall = {1e-6, 1e-6, 1e-6}; |
167 |
> |
static COLOR csmall = {.5*MINLUM, .5*MINLUM, .5*MINLUM}; |
168 |
|
COLOR cmon; |
169 |
|
double lum, slum; |
170 |
|
register double d; |
172 |
|
|
173 |
|
if (tmTop == NULL) |
174 |
|
returnErr(TM_E_TMINVAL); |
175 |
< |
if (ls == NULL | scan == NULL | len < 0) |
175 |
> |
if ((ls == NULL) | (scan == NULL) | (len < 0)) |
176 |
|
returnErr(TM_E_ILLEGAL); |
177 |
|
for (i = len; i--; ) { |
178 |
< |
if (tmNeedMatrix(tmTop)) /* get monitor RGB */ |
178 |
> |
if (tmNeedMatrix(tmTop)) { /* get monitor RGB */ |
179 |
|
colortrans(cmon, tmTop->cmat, scan[i]); |
180 |
< |
else { |
180 |
> |
} else { |
181 |
|
cmon[RED] = tmTop->inpsf*scan[i][RED]; |
182 |
|
cmon[GRN] = tmTop->inpsf*scan[i][GRN]; |
183 |
|
cmon[BLU] = tmTop->inpsf*scan[i][BLU]; |
245 |
|
|
246 |
|
if (tmTop == NULL) |
247 |
|
returnErr(TM_E_TMINVAL); |
248 |
< |
if (ls == NULL | scan == NULL | len < 0) |
248 |
> |
if ((ls == NULL) | (scan == NULL) | (len < 0)) |
249 |
|
returnErr(TM_E_ILLEGAL); |
250 |
|
for (i = len; i--; ) |
251 |
|
if (scan[i] <= TM_NOLUM) { |
392 |
|
float *cumf; |
393 |
|
int brt0, histlen, threshold, ceiling, trimmings; |
394 |
|
double logLddyn, Ldmin, Ldavg, Lwavg, Tr, Lw, Ld; |
395 |
< |
int4 histot; |
395 |
> |
int32 histot; |
396 |
|
double sum; |
397 |
|
register double d; |
398 |
|
register int i, j; |
417 |
|
histot += tmTop->histo[i]; |
418 |
|
sum += (j -= HISTEP) * tmTop->histo[i]; |
419 |
|
} |
420 |
< |
threshold = histot*.025 + .5; |
420 |
> |
threshold = histot*0.005 + .5; |
421 |
|
if (threshold < 4) |
422 |
|
returnErr(TM_E_TMFAIL); |
423 |
|
Lwavg = tmLuminance( (double)sum / histot ); |
430 |
|
/* clamp histogram */ |
431 |
|
histo = (int *)malloc(histlen*sizeof(int)); |
432 |
|
cumf = (float *)malloc((histlen+2)*sizeof(float)); |
433 |
< |
if (histo == NULL | cumf == NULL) |
433 |
> |
if ((histo == NULL) | (cumf == NULL)) |
434 |
|
returnErr(TM_E_NOMEM); |
435 |
|
cumf[histlen+1] = 1.; /* guard for assignment code */ |
436 |
|
for (i = histlen; i--; ) /* make malleable copy */ |
494 |
|
int len; |
495 |
|
{ |
496 |
|
static char funcName[] = "tmMapPixels"; |
497 |
< |
register int4 li, pv; |
497 |
> |
register int32 li, pv; |
498 |
|
|
499 |
|
if (tmTop == NULL || tmTop->lumap == NULL) |
500 |
|
returnErr(TM_E_TMINVAL); |
501 |
< |
if (ps == NULL | ls == NULL | len < 0) |
501 |
> |
if ((ps == NULL) | (ls == NULL) | (len < 0)) |
502 |
|
returnErr(TM_E_ILLEGAL); |
503 |
|
while (len--) { |
504 |
|
if ((li = *ls++) < tmTop->mbrmin) { |
540 |
|
{ |
541 |
|
register struct tmStruct *tms2; |
542 |
|
/* special cases first */ |
543 |
< |
if (tms == NULL | tmTop == NULL) |
543 |
> |
if ((tms == NULL) | (tmTop == NULL)) |
544 |
|
return(0); |
545 |
|
if (tms == tmTop) { |
546 |
|
tmTop = tms->tmprev; |