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

Implement color spaces: XYZ and CIE-L*ab #18

Open
Munter opened this issue Mar 17, 2013 · 9 comments
Open

Implement color spaces: XYZ and CIE-L*ab #18

Munter opened this issue Mar 17, 2013 · 9 comments

Comments

@Munter
Copy link
Collaborator

Munter commented Mar 17, 2013

No description provided.

@Munter
Copy link
Collaborator Author

Munter commented Mar 17, 2013

Ping @ianjorgensen

@Munter Munter closed this as completed in ccc8cb3 Mar 17, 2013
@Munter
Copy link
Collaborator Author

Munter commented Mar 17, 2013

Released v2.3.4 with this.

Unit tests missing though, so I hope I got it right.

@ianjorgensen
Copy link

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!

@Munter
Copy link
Collaborator Author

Munter commented Mar 17, 2013

So those unit tests are needed after all :)

@Munter Munter reopened this Mar 17, 2013
@ianjorgensen
Copy link

:), 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

@Munter
Copy link
Collaborator Author

Munter commented Mar 17, 2013

I think I know the problem. Basic assumption failure. All channels in all color spaces are clamped to the range [0;1] in one-color to keep precision in longer chains of conversions and adjustments.

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.

@Munter
Copy link
Collaborator Author

Munter commented Mar 17, 2013

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...

@Munter
Copy link
Collaborator Author

Munter commented May 9, 2015

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

@Munter
Copy link
Collaborator Author

Munter commented Jan 10, 2019

This might be a relevant reference implementation: http://www.easyrgb.com/en/math.php

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

No branches or pull requests

2 participants