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, ...)
       
       rgbImage(r, g, b)
       channelMix(r, g, b)

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

   r,g,b: Objects of class 'Image'. 

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

     'channelMix' uses the following formula to calculate the mix: 'mix
     = sqrt(r^2+g^+b^2)'. Any of the values can be missing.

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

     'rgbImage' generated a TrueColor image using 'r', 'g' and 'b' as
     values for red, green and blue channels correspondingly.

     'channelMix' generates a grayscale image as if the image was
     converted from a TrueColor one that was composed using 'r', 'g'
     and 'b'.

_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'

