rgbArray {RNifti} | R Documentation |
RGB arrays
Description
The rgbArray
function constructs an integer array whose values are
byte-packed representations of 8-bit RGBA colour values. The channels
attribute (with value 3 or 4) indicates how many channels are being used.
The resulting array can be used to construct an RGB(A) NIfTI image, or
converted to standard R colour strings using the as.character
method.
The indexing method returns another object of the same type.
Usage
rgbArray(red, green, blue, alpha, max = NULL, dim = NULL, ...)
## S3 method for class 'rgbArray'
x[i, j, ..., drop = TRUE]
## S3 method for class 'rgbArray'
as.raster(x, ...)
## S3 method for class 'rgbArray'
as.character(x, flatten = TRUE, ...)
Arguments
red |
A numeric vector (or array) of red channel values. If this is the only channel argument, it can also be a character vector of colour values (including alpha, if required), or a numeric array whose last dimension is 2 (for grey + alpha), 3 (for RGB) or 4 (for RGBA). |
green , blue , alpha |
Numeric vectors (or arrays) containing values for
the appropriate channel. These will be combined with the |
max |
The maximum possible value for any channel. The default is 255 when the data is of integer mode, and 1 otherwise. Values above this, or below zero, will be clipped to the appropriate extreme. |
dim |
An integer vector of dimensions for the final array. The
dimensions of |
... |
For |
x |
An |
i , j |
Index vectors, which are passed to the |
drop |
Whether or not to drop unitary dimensions. |
flatten |
Logical value. If |
Value
rgbArray
and the indexing ([
) method return an
integer-mode array of class "rgbArray"
. The as.raster
method returns a raster
object, valid for 2D arrays only. The
as.character
method returns a character-mode vector of colour
strings with or without dimensions.
Note
The values of an "rgbArray"
are not easily interpreted, and
may depend on the endianness of the platform. For manipulation or use as
colours they should generally be converted to character mode, or the
channels extracted using the channels
function.
Author(s)
Jon Clayden <code@clayden.org>