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
HCY Color wheel and HCYColor HSV interconversion bug fix [ Patch included :D ] #1167
Comments
|
Also another problem: If libmypaint uses 16bit fixed point linear color space, then Y (luma) and Y' (luminance) should be the same value. Then why would a gamma-corrected canvas display and color picker show otherwise (where Y stay the same but perpetually it's non uniform?) |
|
Oh I see the problem is actually mentioned long before in here... (WE REALLY NEED TO SOLVE THIS?) #890 I dug in the colour representation all day on the problem with Y, Y' and L*. Here's what I found:
I think we should use L* (as in Lab) or Y (But I messed around with code I can't seem to find a way to get a "gamma corrected Y" solution? My math isn't good.), yet I don't know how to get rgb (be it linear or gamma-ed) from a L* or Y correctly. from Wikipedia https://en.wikipedia.org/wiki/Relative_luminance :
I think the best solution now is to have a look at how Krita gets that color and try to Also, A native 16bit canvas would get around these problems, but I see legacy code for gamma/eotf/whatever thing all over the place so I imagine that could be some work... @briend Any ideas? |
|
Krita HSY' to RGB: https://github.com/KDE/krita/blob/4cca3e96003e9267b114052abdba45d1afb718f2/libs/pigment/KoColorConversions.cpp#L423 A wrapper function, note it has a gamma correction on the Y before doing the stuff: https://github.com/KDE/krita/blob/4cca3e96003e9267b114052abdba45d1afb718f2/libs/ui/canvas/kis_display_color_converter.cpp#L660 Tried to do an additional pow 2.2, not working properly in mypaint :( Otherwise it could be related to lcms: |
|
Update: I used the HSY' code from Krita, it gives exactly the same result as the one in mypaint... I think it's gonna largely be due to lcms. I'm compiling Krita and try to mess with the code and see if it gives any more detail. Update 2: Indeed the brightness is corrected using lcms (where it corrects to a certain profile, srgb? I still not understand why it needs to be corrected again, maybe it's for srgb->luminance correction with D65 or whatever, I need to check that part of the lcms code, it's likely gonna be converted to YCC/XYZ model then lab or something like that). I commented out the lcms delinearize code and immediately it produced the same result (And verifiable in GIMP using Luma desaturation). So if we are to solve this, we need to use lcms in some capacity, at least in the color wheel. (The high saturation is also because krita uses H[S]Y' not H[C]Y). I'm then gonna see if I can get that lcms function to work with mypaint hcy functions. Note that the brightness slider is actually not linear in this screenshot, the middle point only has rgb about 54. The behavior in MyPaint is actually correct, it only lacks that final mystery profile stage. |
|
Update: I found the problem is actually related to cairo drawing. The mixing isn't linear. I draw the gradients manually and it matches rec709 perfectly. If I do linear rec 709 it's perfect in grayscale brightness, but now the color picker will jump to a lower Y if I select some colors on the edge... still investigating. |
|
OK I fixed everything now by myself XD I'm using rec709 coeffs for the palette, but it can be changed to others. I'm gonna update a diff here in a short while Actual problems, the way to correctly handle them:
|
|
Here's the patch: HCY Color wheel correct display. This patch contains:
|
|
In the mean time I also found out HSLuv could be even more useful, because Luv is supposedly flatter than Y', and it can apply different color matrix to transform RGB to XYZ, like Adobe/CIE Dxx/whatever. I'm gonna make a similar color picker for using it. |
|
Working with a weighed sum of r, g and b only makes sense if you are dealing with linear values. Summing sRGB values doesn't make sense. So, the use of linearize() and delinearize() makes sense and gives better results. Theoretically, https://en.wikipedia.org/wiki/CIELAB_color_space#Cylindrical_model makes more sense when considering human perception. But then you run into the problem of how only a part of that can be represented by sRGB. The general problem is shown by how you can display a very pure blue, but it will be dim. You can only get a nice circle if you limit saturation and brightness. |




Update: I managed to fix all the problems described in this thread. Scroll to the bottom to see patch and description.
:D
Description of the problem
Because I was researching about the perpetual brightness and chroma, and I always felt that the HCY picker isn't quite "flat". They always show some strips with rather high chroma. (But better than HSY' picker in Krita because the saturation is much more comfortable) In theoy it should be very flat as the values are perpetually adjusted, as in Y' (Luminance).
Looks to me Kirta handles this much more correctly? The color wheel is flat, and also the blue Y slider looks much more linear as well.
Also I think somewhere in the conversion there's a problem, and this is how you can produce it:
This does look like a precision issue (because internally it's 16bit fixed point?), but I think this is also related to the conversion method used in
HCYColor, because the resulting circle is not exactly "flat" looking. If we use the screenshot of the color wheel and put it into GIMP, desaturate it using HCY' (Luminance option) and Luma, we can actually see when using Luma the desaturated result is much closer to flat, which considering bit depth, is consistent with MyPaint HCY conversion algorithm (which is luma).So the question becomes, can we have Y' (Luminance) as our picker model? Because it's even closer to perpetual brightness.
Basic system details
MyPaint version: [Doesn't really matter, it's latest, and this part hasn't seen changes since forever]
Operating system: Xubuntu 20.04
Desktop environment: XFCE
The text was updated successfully, but these errors were encountered: