I'm using the colorsys lib of Python:
import colorsys
colorsys.rgb_to_hsv(64, 208, 61)
output:(0.16666666666666666, 0, 208)
But this output is wrong, this is the true value using a RGB to HSV online converter: RGB to HSV
What's going on?
colorsys
takes its values in the range 0
to 1
:
Coordinates in all of these color spaces are floating point values. In the YIQ space, the Y coordinate is between 0 and 1, but the I and Q coordinates can be positive or negative. In all other spaces, the coordinates are all between 0 and 1.
You need to divide each of the values by 255.
to get the expected output:
>>> colorsys.rgb_to_hsv(64/255., 208/255., 61/255.)
(0.3299319727891157, 0.7067307692307692, 0.8156862745098039)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With