12 |
|
#include "copyright.h" |
13 |
|
|
14 |
|
#include <stdio.h> |
15 |
+ |
#include <stdlib.h> |
16 |
|
#include <math.h> |
17 |
|
#include "tmprivat.h" |
18 |
|
#include "tmerrmsg.h" |
420 |
|
} |
421 |
|
|
422 |
|
|
422 |
– |
static int |
423 |
– |
tmNewMap( /* allocate new tone-mapping array */ |
424 |
– |
TMstruct *tms |
425 |
– |
) |
426 |
– |
{ |
427 |
– |
if (tms->lumap != NULL && (tms->mbrmax - tms->mbrmin) != |
428 |
– |
(tms->hbrmax - tms->hbrmin)) { |
429 |
– |
free((MEM_PTR)tms->lumap); |
430 |
– |
tms->lumap = NULL; |
431 |
– |
} |
432 |
– |
tms->mbrmin = tms->hbrmin; |
433 |
– |
tms->mbrmax = tms->hbrmax; |
434 |
– |
if (tms->mbrmin > tms->mbrmax) |
435 |
– |
return 0; |
436 |
– |
if (tms->lumap == NULL) |
437 |
– |
tms->lumap = (unsigned short *)malloc(sizeof(unsigned short)* |
438 |
– |
(tms->mbrmax-tms->mbrmin+1)); |
439 |
– |
return(tms->lumap != NULL); |
440 |
– |
} |
441 |
– |
|
442 |
– |
|
423 |
|
int |
424 |
|
tmFixedMapping( /* compute fixed, linear tone-mapping */ |
425 |
|
TMstruct *tms, |
477 |
|
logLddyn = log(Lddyn); |
478 |
|
Ldavg = sqrt(Ldmax*Ldmin); |
479 |
|
i = HISTI(tms->hbrmin); |
480 |
< |
brt0 = MINBRT + HISTEP/2 + i*HISTEP; |
480 |
> |
brt0 = HISTV(i); |
481 |
|
histlen = HISTI(tms->hbrmax) + 1 - i; |
482 |
|
/* histogram total and mean */ |
483 |
|
histot = 0; sum = 0; |
595 |
|
} |
596 |
|
|
597 |
|
|
618 |
– |
|
619 |
– |
|
598 |
|
TMstruct * |
599 |
|
tmDup( /* duplicate top tone mapping */ |
600 |
|
TMstruct *tms |
669 |
|
tmMesofact[i-BMESLOWER] = 256. * |
670 |
|
(tmLuminance(i) - LMESLOWER) / |
671 |
|
(LMESUPPER - LMESLOWER); |
672 |
+ |
} |
673 |
+ |
|
674 |
+ |
|
675 |
+ |
int |
676 |
+ |
tmNewMap( /* allocate new tone-mapping array */ |
677 |
+ |
TMstruct *tms |
678 |
+ |
) |
679 |
+ |
{ |
680 |
+ |
if (tms->lumap != NULL && (tms->mbrmax - tms->mbrmin) != |
681 |
+ |
(tms->hbrmax - tms->hbrmin)) { |
682 |
+ |
free((MEM_PTR)tms->lumap); |
683 |
+ |
tms->lumap = NULL; |
684 |
+ |
} |
685 |
+ |
tms->mbrmin = tms->hbrmin; |
686 |
+ |
tms->mbrmax = tms->hbrmax; |
687 |
+ |
if (tms->mbrmin > tms->mbrmax) |
688 |
+ |
return 0; |
689 |
+ |
if (tms->lumap == NULL) |
690 |
+ |
tms->lumap = (unsigned short *)malloc(sizeof(unsigned short)* |
691 |
+ |
(tms->mbrmax-tms->mbrmin+1)); |
692 |
+ |
return(tms->lumap != NULL); |
693 |
|
} |
694 |
|
|
695 |
|
|