--- ray/src/common/tonemap.c 2021/05/04 21:50:54 3.51 +++ ray/src/common/tonemap.c 2022/01/15 16:57:46 3.54 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: tonemap.c,v 3.51 2021/05/04 21:50:54 greg Exp $"; +static const char RCSid[] = "$Id: tonemap.c,v 3.54 2022/01/15 16:57:46 greg Exp $"; #endif /* * Tone mapping functions. @@ -95,7 +95,7 @@ tmSetSpace( /* set input color space for conversions TMstruct *tms, RGBPRIMP pri, double sf, -MEM_PTR dat +void *dat ) { static const char funcName[] = "tmSetSpace"; @@ -321,7 +321,9 @@ int len cmon[BLU] += d; } } else if (tms->flags & TM_F_BW) { - cmon[RED] = cmon[GRN] = cmon[BLU] = lum; + int j = 3; + while (j--) cs[3*i+j] = tms->cdiv[j]/(TM_BRES>>8); + continue; } d = tms->clf[RED]*cmon[RED]/lum; cs[3*i ] = d>=.999f ? 255 : gamtab[(int)(1024.f*d)]; @@ -491,10 +493,10 @@ double Ldmax } if (!histot) returnErr(TM_E_TMFAIL); - threshold = histot/40 + 1; + threshold = histot/500 + 1; Lwavg = tmLuminance( (double)sum / histot ); /* use linear tone mapping? */ - if (tms->flags & TM_F_LINEAR || threshold < 4 || + if (tms->flags & TM_F_LINEAR || tms->hbrmax - tms->hbrmin < TM_BRTSCALE*logLddyn) goto linearmap; /* clamp histogram */