Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined behavior outside of sRGB gamut: JCh and Jab colors return displayable RGB values #5

Open
connorgr opened this issue Nov 16, 2016 · 1 comment
Labels

Comments

@connorgr
Copy link
Owner

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:

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

This is consistent with the Colorspacious Python library as well as Billy Bigg's C implementation. It looks like this may not be the case with the Colour Python package, but their implementation differs so much I haven't had time to do a comprehensive comparison.

@connorgr connorgr added the bug label Nov 16, 2016
@connorgr
Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant