You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rgb2hsv_approximate returns completely wrong color #436
Paint.net says rgb(255,153,0) results in hsv(36,100,100) for 360 degrees which would be hsv(26,255,255) for FastLED if I'm not mistaken. Instead rgb2hsv_approximate returns hsv(122,255,255) in FastLED which is not even closely orange-ish (it's green).
Thanks, I was wondering if there are some "weird magics" about this conversion or it is an implementation of formulas describe here (first google result typing "rgb to hsv").
I'm also having a similar issue. Trying to convert an RGB palette to HSV to make it easier to intuitively change the colors. Most of them are close enough, but one color that is mostly green comes out as a dim blue:
I’m hoping to make some progress on this this week. Thank you for the examples to reproduce— that’ll help me fix it that much more easily. Much appreciated.
This is still broken. I have used alexa to set the colours and red is red, green is green, blue is blue
but orange I would say looks like cyan. Magenta is just blue and yellow is green.
So basically all the secondary colours are way out.
Since alexa only has a few colours I guess I can bodge it but we should get it right. Is this to do with the hue only have 256 degrees instead of 360?
actually I found an interesting thing that might help. I had the LED order wrong so I had GRB. I then shifted the bytes around so that it looked ok. This then gives me the right colours, but when you colour fade its wrong.
I've been looking into this and while I haven't 'fixed' any of the existing functions I've added more color accurate conversion functions in the pr linked above.
More info in the pr, but here are the conversions from this thread rerun with the new functions:
"Request Col_Set" comes from the calling function from before this code, this is printing purely the color string. this string is than converted into an actual number via strtol();
Color codes are OK until the rgb2hsv_approximate. This happens only in for those orange-ish colors. Also, colors close to Hue = 255 are a bit "very" approximated (it returns red all the time untill it suddenly jumps to a purple-ish color)
cad435
Edit; I implemented the "rgb2hsv_precise" from @5chmidti and can confirm this works how I expected it to work :) Thank you!
Edit2: Out of curiosity I did some measurements. First a FastLED "rgb2hsv_approximate" and than a "rgb2hsv_precise". At least on the ESP32 the "precise" implementation seems to be 2 times faster than the approximate??
Activity
kriegsman commentedon Apr 7, 2017
Hi and thanks for the detailed bug report!
I'll take a look at the code and see if I can reproduce it, and if so get to the bottom of it.
srwi commentedon Apr 7, 2017
Great, thank you! By the way I am using the latest commit (06a5abc) at the moment. If you need anything else let me know!
fabianoriccardi commentedon Nov 12, 2018
Any news about this issue? I'm experiencing the same bug...
kriegsman commentedon Nov 12, 2018
Thanks for the reminder. I’ll try to take a look.
fabianoriccardi commentedon Nov 13, 2018
Thanks, I was wondering if there are some "weird magics" about this conversion or it is an implementation of formulas describe here (first google result typing "rgb to hsv").
Maybe I could help this issue
PhotonicVelocity commentedon Jan 12, 2019
I'm also having a similar issue. Trying to convert an RGB palette to HSV to make it easier to intuitively change the colors. Most of them are close enough, but one color that is mostly green comes out as a dim blue:
Interestingly, changing the original color to
0 235 52gets a much more accurate (but still not as good as the rest) result of0 202 52mike2003 commentedon Jan 26, 2020
Bug - read rgb2hsv_approximate and h=33
h++ and write back to leds[i]
Next read h=33 again!
kriegsman commentedon Jan 26, 2020
I’m hoping to make some progress on this this week. Thank you for the examples to reproduce— that’ll help me fix it that much more easily. Much appreciated.
Modifikator commentedon Aug 2, 2020
Is there progress in solving this problem?
DrJaymz commentedon Sep 11, 2020
This is still broken. I have used alexa to set the colours and red is red, green is green, blue is blue
but orange I would say looks like cyan. Magenta is just blue and yellow is green.
So basically all the secondary colours are way out.
Since alexa only has a few colours I guess I can bodge it but we should get it right. Is this to do with the hue only have 256 degrees instead of 360?
DrJaymz commentedon Sep 11, 2020
roses are red violets are blue and my orange is green and so is my loo.
DrJaymz commentedon Sep 11, 2020
actually I found an interesting thing that might help. I had the LED order wrong so I had GRB. I then shifted the bytes around so that it looked ok. This then gives me the right colours, but when you colour fade its wrong.
DrJaymz commentedon Sep 12, 2020
here's my temp fix.
if(r == 255 && g==166) new_colour.h = 21; //Otherwise it thinks its green which it clearly aint.
5chmidti commentedon Oct 1, 2020
I've been looking into this and while I haven't 'fixed' any of the existing functions I've added more color accurate conversion functions in the pr linked above.
More info in the pr, but here are the conversions from this thread rerun with the new functions:
and from the first post:
cad435 commentedon Jul 31, 2022
This bug still exists:
Console Output:
"Request Col_Set" comes from the calling function from before this code, this is printing purely the color string. this string is than converted into an actual number via strtol();
Color codes are OK until the rgb2hsv_approximate. This happens only in for those orange-ish colors. Also, colors close to Hue = 255 are a bit "very" approximated (it returns red all the time untill it suddenly jumps to a purple-ish color)
Edit; I implemented the "rgb2hsv_precise" from @5chmidti and can confirm this works how I expected it to work :) Thank you!
Edit2: Out of curiosity I did some measurements. First a FastLED "rgb2hsv_approximate" and than a "rgb2hsv_precise". At least on the ESP32 the "precise" implementation seems to be 2 times faster than the approximate??
fix(color): stop rgb2hsv_approximate wrapping orange into green (#436) (