rgb2hsv                package:hexbin                R Documentation

_N_u_m_e_r_i_c _C_o_n_v_e_r_s_i_o_n _o_f _R_G_B _t_o _H_S_V _C_o_l_o_r _S_p_a_c_e

_D_e_s_c_r_i_p_t_i_o_n:

     Given a 3-row matrix of RGB (Red, Green, Blue) values in [0,1]
     return a similar matrix of HSV (Hue, Saturation, Value) values.

_U_s_a_g_e:

     rgb2hsv(r, g = NULL, b = NULL, delta = 1)

_A_r_g_u_m_e_n_t_s:

       r: vector of "red" values in [0,1], or 3-row rgb matrix.

       g: vector of "green" values, or 'NULL' when 'r' is a matrix.

       b: vector of "blue" values, or 'NULL' when 'r' is a matrix.

   delta: a "gamma correction".

_V_a_l_u_e:

_S_e_e _A_l_s_o:

     'hsv', 'rgb', 'col2rgb'.

_E_x_a_m_p_l_e_s:

     256* (rgb3 <- floor(256 * matrix(runif(3*12), 3,12))/256)
     (hsv3 <- rgb2hsv(rgb3))
     rgbBack <- col2rgb(hsv(h=hsv3[1,], s=hsv3[2,], v=hsv3[3,]))
     table(256*rgb3 - rgbBack)# not all 0; I had about half 1's
     stopifnot(max(1 - c(256*rgb3) / c(rgbBack)) < 0.01)

