[iargb2hsv] [Up] [iargb2ycbcr] Color Processing

iahsv2rgb
Convert HSV to RGB color model.

Synopsis

g = iahsv2rgb( f )

Implemented in Python.

Input

f Image. Gray-scale (uint8 or uint16) or binary image (logical).

HSV color model.

Output

g Image. Gray-scale (uint8 or uint16) or binary image (logical).

True color RGB image.

Description

Converts hue-saturation-value to red-green-blue colors.

Examples

>>> 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.]]

Source Code

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] http://www.python.org