| 270 |
|
COLOR ciecolor; |
| 271 |
|
|
| 272 |
|
spec_cie(ciecolor, s, e); |
| 273 |
< |
cie_rgb(col, ciecolor); |
| 273 |
> |
colortrans(col, xyz2rgbmat, ciecolor); |
| 274 |
|
} |
| 275 |
|
|
| 276 |
|
|
| 278 |
|
spec_dot( /* spectrum dot-product with cumulative observer */ |
| 279 |
|
SCOLOR scol, |
| 280 |
|
int ncs, |
| 281 |
< |
float wlpt[4], |
| 281 |
> |
const float wlpt[4], |
| 282 |
|
const unsigned short cumul[], |
| 283 |
|
int wlmin, |
| 284 |
|
int wlmax |
| 297 |
|
|
| 298 |
|
while (n < ncs) { |
| 299 |
|
int wl0 = wl1; |
| 300 |
< |
wl1 = (int)(ncs==3 ? wlpt[ncs-1-n] : wlpt[3] + (n+1)*wlstp); |
| 300 |
> |
wl1 = (int)(ncs==3 ? wlpt[2-n] : wlpt[3] + (n+1)*wlstp); |
| 301 |
|
if (wl1 >= wlmax) { |
| 302 |
< |
sum += (65535 - cumul[wl0-wlmin]) * scol[n]; |
| 302 |
> |
sum += (65535 - cumul[wl0-wlmin]) * scol[ncs-1-n]; |
| 303 |
|
break; |
| 304 |
|
} |
| 305 |
< |
sum += (cumul[wl1-wlmin] - cumul[wl0-wlmin]) * scol[n++]; |
| 305 |
> |
sum += (cumul[wl1-wlmin] - cumul[wl0-wlmin]) * scol[ncs-1-n++]; |
| 306 |
|
} |
| 307 |
|
return(sum * (1./65535.)); |
| 308 |
|
} |
| 313 |
|
COLOR col, |
| 314 |
|
SCOLOR scol, |
| 315 |
|
int ncs, |
| 316 |
< |
float wlpt[4] |
| 316 |
> |
const float wlpt[4] |
| 317 |
|
) |
| 318 |
|
{ |
| 319 |
|
if (ncs == 3) { /* not a spectrum! */ |
| 331 |
|
COLOR col, |
| 332 |
|
SCOLOR scol, |
| 333 |
|
int ncs, |
| 334 |
< |
float wlpt[4] |
| 334 |
> |
const float wlpt[4] |
| 335 |
|
) |
| 336 |
|
{ |
| 337 |
|
COLOR ciecolor; |
| 346 |
|
|
| 347 |
|
|
| 348 |
|
double |
| 349 |
< |
scolor_photopic( /* compute scotopic integral for spectral color */ |
| 350 |
< |
SCOLOR scol |
| 349 |
> |
scolor2photopic( /* compute scotopic integral for spectral color */ |
| 350 |
> |
SCOLOR scol, |
| 351 |
> |
int ncs, |
| 352 |
> |
const float wlpt[4] |
| 353 |
|
) |
| 354 |
|
{ |
| 355 |
< |
if (NCSAMP == 3) |
| 355 |
> |
if (ncs == 3) |
| 356 |
|
return bright(scol); |
| 357 |
|
|
| 358 |
< |
return(spec_dot(scol, NCSAMP, WLPART, cie_y_cumul, CIE_Y_WLMIN, CIE_Y_WLMAX)); |
| 358 |
> |
return(spec_dot(scol, ncs, wlpt, cie_y_cumul, CIE_Y_WLMIN, CIE_Y_WLMAX)); |
| 359 |
|
} |
| 360 |
|
|
| 361 |
|
|
| 362 |
|
double |
| 363 |
+ |
scolor2scotopic( /* compute Y channel for spectral color */ |
| 364 |
+ |
SCOLOR scol, |
| 365 |
+ |
int ncs, |
| 366 |
+ |
const float wlpt[4] |
| 367 |
+ |
) |
| 368 |
+ |
{ |
| 369 |
+ |
return(spec_dot(scol, ncs, wlpt, scotopic_cumul, SCOTOPIC_WLMIN, SCOTOPIC_WLMAX)); |
| 370 |
+ |
} |
| 371 |
+ |
|
| 372 |
+ |
|
| 373 |
+ |
double |
| 374 |
+ |
scolor2melanopic( /* compute melanopic integral for spectral color */ |
| 375 |
+ |
SCOLOR scol, |
| 376 |
+ |
int ncs, |
| 377 |
+ |
const float wlpt[4] |
| 378 |
+ |
) |
| 379 |
+ |
{ |
| 380 |
+ |
return(spec_dot(scol, ncs, wlpt, melanopic_cumul, MELANOPIC_WLMIN, MELANOPIC_WLMAX)); |
| 381 |
+ |
} |
| 382 |
+ |
|
| 383 |
+ |
|
| 384 |
+ |
double |
| 385 |
+ |
scolor_photopic( /* compute scotopic integral for spectral color */ |
| 386 |
+ |
SCOLOR scol |
| 387 |
+ |
) |
| 388 |
+ |
{ |
| 389 |
+ |
return(scolor2photopic(scol, NCSAMP, WLPART)); |
| 390 |
+ |
} |
| 391 |
+ |
|
| 392 |
+ |
|
| 393 |
+ |
double |
| 394 |
|
scolor_scotopic( /* compute Y channel for spectral color */ |
| 395 |
|
SCOLOR scol |
| 396 |
|
) |
| 397 |
|
{ |
| 398 |
< |
return(spec_dot(scol, NCSAMP, WLPART, scotopic_cumul, SCOTOPIC_WLMIN, SCOTOPIC_WLMAX)); |
| 398 |
> |
return(scolor2scotopic(scol, NCSAMP, WLPART)); |
| 399 |
|
} |
| 400 |
|
|
| 401 |
|
|
| 404 |
|
SCOLOR scol |
| 405 |
|
) |
| 406 |
|
{ |
| 407 |
< |
return(spec_dot(scol, NCSAMP, WLPART, melanopic_cumul, MELANOPIC_WLMIN, MELANOPIC_WLMAX)); |
| 407 |
> |
return(scolor2melanopic(scol, NCSAMP, WLPART)); |
| 408 |
|
} |
| 409 |
|
|
| 410 |
|
|