[Numpy-discussion] RGB <-> HSV in numpy?

He Shiming heshiming@gmail....
Sat Aug 20 03:01:42 CDT 2011


Hi,

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().

How do I run RGB <-> HSV conversion on the nd array? I'd like to keep
SV values in the range of 0-1, and H in 0-360. Thank you.

-- 
Best regards,
He Shiming


More information about the NumPy-Discussion mailing list