[Numpy-discussion] RGB <-> HSV in numpy?
Sat Aug 20 03:17:26 CDT 2011
On 2011-08-20, at 4:01 AM, He Shiming wrote:
> I'm wondering how to do RGB <-> HSV conversion in numpy. I found a
> couple solutions through stackoverflow, but somehow they can't be used
> in my array format. I understand the concept of conversion, but I'm
> not that familiar with numpy.
> My source buffer format is 'RGBA' sequence. I can take it into numpy
> via: numpy.fromstring(data, 'B').astype('I'). So that nd[0::4] becomes
> the array for the red channel. After color manipulation, I'll convert
> it back by nd.astype('B').tostring().
There are functions for this available in scikits.image:
Although you may need to reshape it with reshape(arr, (width, height, 4)) or something similar first.
More information about the NumPy-Discussion