channel {EBImage}R Documentation

Color conversion

Description

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.

Usage

    # S4 method for classes 'Image' and 'ANY':
    channel(x, mode)

Aarguments

x
A vector, matrix or array of integer's, numeric's or character's; or an object of Image-class.
mode
A character giving the target mode for conversion. See section 'Conversion Modes' below.

Value

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

Conversion modes are case insensitive.

rgb
The result is a TrueColor representation of the input, its class is or includes integer, i.e. integer array, integer-based image.
gray
The resul is a Grayscale representation of the input, its class is or includes numeric. Synonim: grey
red, green, blue
The result image is a Grayscale image corresponding to the intensity of the channel requested, its class is numeric-based.
asred, asgreen, asblue
The result image is a TrueColor image with the input converted to the intensity of the specified color channel, its class is integer-based.
x11
The result is a 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.

Author(s)

Oleg Sklyar: osklyar@ebi.ac.uk

See Also

Image-class, Image, read.image, write.image

Examples

  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"))
  }


[Package EBImage version 2.0.1 Index]