488 |
|
histot += tms->histo[i]; |
489 |
|
sum += (double)(j -= HISTEP) * tms->histo[i]; |
490 |
|
} |
491 |
– |
threshold = histot*0.002 + .5; |
491 |
|
if (!histot) |
492 |
|
returnErr(TM_E_TMFAIL); |
493 |
+ |
threshold = histot/40 + 1; |
494 |
|
Lwavg = tmLuminance( (double)sum / histot ); |
495 |
|
/* use linear tone mapping? */ |
496 |
|
if (tms->flags & TM_F_LINEAR || threshold < 4 || |
534 |
|
free(cumf); |
535 |
|
goto linearmap; |
536 |
|
} |
537 |
< |
} while (trimmings > threshold); |
537 |
> |
} while (40*trimmings > histot); |
538 |
|
/* allocate space for mapping */ |
539 |
|
if (!tmNewMap(tms)) |
540 |
|
returnErr(TM_E_NOMEM); |