HSV to RGB Color Conversion

后端 未结 9 1685
离开以前
离开以前 2020-12-14 01:16

Is there a way to convert HSV color arguments to RGB type color arguments using pygame modules in python? I tried the following code, but it returns ridiculous values.

9条回答
  •  青春惊慌失措
    2020-12-14 01:45

    I found the following code to work with images represented as numpy ndarrays:

    from skimage.io import imread
    import matplotlib.colors as mcolors
    img = imread( 'my_image.png' )
    img_hsv = mcolors.rgb_to_hsv( img )
    img_hsv = img_hsv / (1.0, 1.0, 255.0)
    

    The last division was useful to convert to a floating representation between 0.0 and 1.0, as for some reason the last component originally ranged between 0 and 255.

提交回复
热议问题