channel {EBImage} | R Documentation |
channel
allows to convert images and other data in vectors,
arrays or matrices representing colors from one mode to another.
The supported modes are: TrueColor (data type: integer
),
Grayscale (numeric
) and X11 strings (character
).
The mode of the argument is determined automatically from its atomic type.
# S4 method for classes 'Image' and 'ANY': channel(x, mode)
integer
's, numeric
's or
character
's; or an object of Image-class
.
For an argument of Image-class
– a new object of
Image-class
in all modes except 'X11'
. In case of
'X11'
– a character
vector of the same length as that
of the image.
For vectors and arrays – be a vector
of the same size.
Conversion modes are case insensitive.
rgb
integer
, i.e. integer array,
integer-based image. gray
numeric
. Synonim: grey
red, green, blue
numeric
-based. asred, asgreen, asblue
integer
-based. x11
vector
of character
's
each giving the input colors or intensities as X11 strings in
the hex representation starting with a sharp sign.
If 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.
Oleg Sklyar: osklyar@ebi.ac.uk
Image-class, Image, read.image, write.image
if ( interactive() ) { 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")) }