channel               package:EBImage               R Documentation

_C_o_l_o_r _a_n_d _i_m_a_g_e _c_o_l_o_r _m_o_d_e _c_o_n_v_e_r_s_i_o_n_s

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

     'channel' allows to convert colors of images and color values
     given in  vectors, arrays or matrices from one mode to another.
     The supported source and target modes are TrueColor (data of type:
     'integer') and Grayscale ('numeric') and X11 strings
     ('character').

     The mode of the argument is determined automatically from its
     type.

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

      
       ## S4 methods for signatures 'x=Image,mode=character'
       ## and 'x=ANY,mode=character'
       channel(x, mode, ...)

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

       x: Either an object of 'Image' or a vector of  'numeric',
          'integer' or 'character'. 

    mode: A character value specifying the target mode for conversion. 
          See 'Conversion Modes' below. 

     ...: Reserved. 

_D_e_t_a_i_l_s:

     Conversion modes:


     '_r_g_b' The result is a true color representation of the input. Its
          class is or includes 'integer', i.e. an integer array or a 
          'TrueColor' integer-based image. 

     '_g_r_a_y' The result is a gray scale representation of the input. Its
          class is or includes 'numeric'. Synonym: 'grey' 

     '_r_e_d, _g_r_e_e_n, _b_l_u_e ' The result is a gray scale representation  of
          the input from only the red, the green or the blue channel
          was extracted, correspondingly. The result's class is
          'numeric'-based. As synonyms single letters 'r, g, b' can be
          used correspondingly.

     '_a_s_r_e_d, _a_s_g_r_e_e_n, _a_s_b_l_u_e' The result is a true color with all the
          data in one channel only, the red, green or blue,
          correspondingly. The result's class is 'integer'-based. As
          synonyms '2r, 2g, 2b' can be used. 

     '_x_1_1' The result is a 'character', which elements represent the
          input colors as X11 strings, i.e. RGB hex codes starting with
          a sharp sign. 

     Conversion modes are case insensitive!

     If the input is a 'character' vector, its values may contain color
     names instead of color hex codes, like 'red, purple, white' etc.
     However, the result of the 'X11' mode will always contain hex
     codes.

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

     For an argument of 'Image' the function returns a new object  of
     'Image' in all modes except ''X11''. In case of ''X11'' it returns
     a 'character' vector of the same length as the image.

     For vectors the function returns a 'vector' of the same size in
     the target mode.

_A_u_t_h_o_r(_s):

     Oleg Sklyar, osklyar@ebi.ac.uk

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

     ' Image, readImage, writeImage '

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

       cl <- channel("pink", "rgb")
       r <- channel( channel(cl, "red"), "asred")
       g <- channel( channel("pink", "green"), "asgreen")
       b <- channel( channel(cl, "blue"), "asblue")
       rgb <- r + g + b
       print( rgb == cl )
       clg <- channel(cl, "gray")
       print( channel(cl, "x11"))
       
       ## further example in 'paintObjects'

