cginternals / webgl-operate

A TypeScript based WebGL rendering framework.
https://webgl-operate.org
MIT License
167 stars 25 forks source link

LAB color space conversion wrong on assumed ranges #194

Closed anne-gropler closed 4 years ago

anne-gropler commented 5 years ago

I searched for different algorithms on how to convert to/from LAB space, and I found our algorithm on other places, e.g. http://www.easyrgb.com/en/math.php

In our current implementation, we assume the LAB values to be in range [0.0, 1.0], however, the algorithm assumes different ranges. Most importantly, the values for a and b can be negative (usually between -128 and 128) in common LAB definitions.

Furthermore, we use "LAB" color space without documenting which kind of LAB: CIELAB (L a b*) or Hunter-LAB.

[...] the CIELAB space, defined years later in 1976, named its coordinates L, a, and b* to distinguish them from Hunter's coordinates.

(source)

cgcostume commented 4 years ago

all fixed - thanks for reporting. The whole conversion is confusing since i found no single truth for CIE Lab conversion and all color converters report different results ...