opened
connorgr
username_0
Some Jab and JCh colors that are far outside of displayable RGB end up registering as defined, and I don't know why. For example:

```js
d3.jch(12,90,90).displayable(); // === true
d3.jch(12,90,90).rgb(); // "rgb(65, 30, 5)"
```

This is consistent with the [Colorspacious](https://github.com/njsmith/colorspacious) Python library as well as Billy Bigg's [C implementation](http://scanline.ca/ciecam02/). It looks like this may not be the case with the [Colour](colour-science.org) Python package, but their implementation differs so much I haven't had time to do a comprehensive comparison.
Undefined behavior outside of sRGB gamut: JCh and Jab colors return displayable RGB values
issue
created
connorgr
username_0
This could be related to https://pdfs.semanticscholar.org/b5a9/0215ad9a1fb6b01f310b3d64305f7c9feb3a.pdf It seems like the CAT02, which is typically packaged with CIECAM02 can result in negative tristimulus values, which might explain why invalid colors are magically appearing.

"The Problem with CAT02 and Its Correction" Changjun Li, Esther Perales, M Ronnier Luo, and Francisco Martínez-Verdú.

**Abstract:**
It was reported that the CAT02 imbedded in the CIECAM02 suffers from predicting
the corresponding colours with negative tristimulus values. To overcome this problem,
a mathematical approach is proposed for modifying the CAT02. This approach
combines the non-negativity constraint for the corresponding colours’ tristimulus
values with the minimisation of the colour differences between the tristimulus values
of the corresponding colours obtained by visual observations and tristimulus values of
the corresponding colours predicted by the model, which resulted in a constrained
non-linear optimisation problem. A revised matrix is established using the MATLAB
routine “ fmincon ”.

The performances of the CAT02 with various matrices including the original CAT02
matrix and the new matrix are tested using the visual data sets and the optimum
colours. Test results show that the CAT02 with the new matrix successfully predicted
corresponding colours’ tristimulus vales without negative values for all optimum
colours and colour matching functions of two standard observers under the test
illuminants considered. However, accuracy with the new matrix for predicting the
visual data becomes about 1 CIELAB colour difference unit worse compared with the
original CAT02. It seems that the accuracy has to be sacrificed in order to ensure the
non-negativity constraint for the tristimulus values of the corresponding colours.
comment