-
Notifications
You must be signed in to change notification settings - Fork 61
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
xyz -> lab conversion #8
Comments
It's a combination of those two sources and a bunch of other. I haven't really kept record of them, but the formulas are quite well known and easy to find. You are welcome to join forces, by the way, if you would be interested. |
I am happy to combine our efforts. I am sharing my thoughts on a few things and would like your input on these as well
Using generics I had to write equations like
I have done some of this work already at least for the cie color spaces. I just have to add the formulas for the some of remaining conversions. I see the api being something like this.
You can check out my library for how it looks.
|
|
I have a working solution for xyY and XYZ using generics, in the generic branch.
Here is my understanding of the white point:
Based on this, the global defaults only apply to the cie colorspaces, the rgb spaces have their own standard white point defined. Having a global default is necessary, your formula for xyz to lab assumes a default value for the white point even though you did not specify it. D65 illumiant with cie1931 2 degree observer is the most commonly recommended one. (sRGB uses this, adobe rgb uses D50 illuminant). So when the user is aware of the multiple colorspaces, we can use it in the FromColor trait to convert the color_space
May be start off with separate struct for each variant like sRGB, LinearSRGB, AdobeRGB etc. I am not sure if an enum vesion for all the rgb spaces will be ergonomic.
|
|
I just read the what it isn't section regarding not a compact format. Part of my motivation to write a color library is that it can be a base for other libraries. If all it takes is adding a variant without alpha for this library to be useful to other libraries, I am inclined to do it. Most of the hard work in this library is figuring the structure of the code and all the conversions. Supporting a non alpha version should be fairly straightforward. All the libraries I have looked at definitely support variants without alpha. I've looked at OpenCV, ImageMagic, Haskell, Elm and Python. Even css supports rgb. Just wanted to let you know my thoughts regarding this. Let me go ahead and implement the generic version for a few color spaces and lets take it from there. |
The thing is that the processing representation and the storage representation doesn't have to be the same. Storing RGBf32 is expensive, but working in RGB8 won't be as easy. That's why I want to separate the two concepts and have these linear intermediate types for operations and conversions, and then encode them back into a more compact format. The current implementation makes use of the
The processing phase is where the I'm not trying to say that you are wrong. I'm just looking at it from different angles. I definitely think you are on to something good, if we can make it work well, but our mental models of it seem to be a bit different. I'm trying to keep the above mentioned work flow in focus, where the processing format is the same, regardless of how the image is stored. It's getting very late over here and I think I have to sleep on this. I'm really looking forwards to where this will lead us. 😄 |
I think I have managed to extract the things to do from here into separate small issues, so I'll go ahead and close this. |
Hey I just started working on a similar library repo.
I noticed your cie -> lab conversion does follow wikipedia or http://www.brucelindbloom.com/index.html?ColorCalculator.html which I used as reference. What is your source for the conversions formulas?
link to the conversion I implemented for reference.
The text was updated successfully, but these errors were encountered: