문제

I wanted to convert from rgb to hsv but the results seem to be unexpected

Following is the code

   import colorsys

   print colorsys.rgb_to_hsv(144, 190, 255)

and it prints following

    (0.5, 0, 255)

where I was expecting it to be

    (215,44,100)

or

    (215,0.44,1.0)

any idea???

Thanks a lot

도움이 되었습니까?

해결책

The documentation of colorsys explains that all colour space coordinates are floating point numbers between 0.0 and 1.0 – rescale your values accordingly to get the desired results:

>>> h, s, v = colorsys.rgb_to_hsv(144/255., 190/255., 255/255.)
>>> 360 * h, 100 * s, 100 * v
(215.13513513513513, 43.529411764705884, 100.0)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top