Search code examples
pythonimagergbpython-3.5hsv

Convert RGB to HSV using [0, 255] range


I have an RGB image that I want to convert to the HSV colorspace. The RGB values in the image array have a range of 0 to 255. However, almost all of the colorspace conversion functions out there require the data to have a range of 0 to 1.

Is there anyway to get around this (short of writing my own conversion function)? If not, what is the fastest way to change the data range from 0, 255 to 0, 1 (the array dimensions vary but are typically [1000, 1000, 3])


Solution

  • You can use preprocessing.MinMaxScaler() from scikit-learn.

    Here is link for more information and examples.