-
Notifications
You must be signed in to change notification settings - Fork 40
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
Implement color spaces: XYZ and CIE-L*ab #18
Comments
Ping @ianjorgensen |
Released v2.3.4 with this. Unit tests missing though, so I hope I got it right. |
Installed form source and tried it, both xyz and l*ab return 1 for all properties. require('onecolor')('#af3421').xyz() and require('onecolor')('#af3421').lab() Must be a quick fix i guess. I saw the link to the formulas in your code, so im using that for now. (http://www.easyrgb.com/index.php?X=MATH) Thanks for helping out! |
So those unit tests are needed after all :) |
:), thats the thing with unit test, when you write them they feel overhead but when you dont write them thats when you need them. im really bad at writing them |
I think I know the problem. Basic assumption failure. All channels in all color spaces are clamped to the range The implementation I made doesn't take this into account, so the channel values, which are most often above 1 will be clamped down to 1. This basic assumption might pose a problem, since the channel ranges in XYZ and Lab aren't equal and maybe not even linear? I'll have to take a better look at this. |
I must say that this is some black magic. I'm down to copy/pasting different reference white point matrices just to get some of the tests working. It seems that even minor differences on the 6th decimal make huge differences. This feels more like guesswork and black magic to me that science. I can't make any of the white point conversion matrices convert to XYZ and back to RGB without errors. And I'm not even testing with our equality function, but only if the resulting hex is equal. If anyone out there is listening in: I need a color conversion expert to tell me what resource to read and implement this from so I can get a working two way conversion for XYZ. And I'm not even looking at LAB yet... |
I'm going to leave this open. If any future drive-by contributors are reading this, please contribute to the library by adding unit tests for color conversions between rgb, xyz and lab. The reason I'm not doing this myself is that I can't find good references with known valid converted values. I'm not going to do any further work on the XYZ and Lab spaces until then |
This might be a relevant reference implementation: http://www.easyrgb.com/en/math.php |
No description provided.
The text was updated successfully, but these errors were encountered: