[iargb2hsv] [Up] [iargb2ycbcr] | Color Processing |
Converts hue-saturation-value to red-green-blue colors.
>>> import Numeric
>>> r = [[4,5,6],[4,2,4]]
>>> g = [[0,1,2],[0,4,0]]
>>> b = [[1,0,2],[1,2,2]]
>>> f = Numeric.zeros((3,2,3))
>>> f[0,:,:], f[1,:,:], f[2,:,:] = r, g, b
>>> print f[0,:,:]
[[4 5 6] [4 2 4]]
>>> print f[1,:,:]
[[0 1 2] [0 4 0]]
>>> print f[2,:,:]
[[1 0 2] [1 2 2]]
>>> g = iargb2hsv(f)
>>> f_ = iahsv2rgb(g)
>>> print f_[0,:,:]
[[ 4. 5. 6.] [ 4. 2. 4.]]
>>> print f_[1,:,:]
[[ 0. 1. 2.] [ 0. 4. 0.]]
>>> print f_[2,:,:]
[[ 1. 0. 2.] [ 1. 2. 2.]]
def iahsv2rgb(f): from Numeric import ravel, reshape, transpose import colorsys g = map(colorsys.hsv_to_rgb, ravel(f[0,:,:]), ravel(f[1,:,:]), ravel(f[2,:,:])) g = 255*reshape(transpose(g), f.shape) return g
[iargb2hsv] [Up] [iargb2ycbcr] | |