This function displays a 2D greyscale or RGB colour image. It is a wrapper
around image
, with more sensible defaults for images. It is (S3)
generic. A method for 3D arrays is provided, which assumes that the third
dimension corresponds to channel (grey/alpha for two channels, red/green/
blue for three, red/green/blue/alpha for four).
display(x, ...)# S3 method for default
display(x, transpose = TRUE, useRaster = TRUE,
add = FALSE, col = grey(0:255/255), ...)
# S3 method for matrix
display(x, ...)
# S3 method for array
display(x, max = NULL, ...)
This function is called for its side-effect of displaying an image on a new R device.
An R object. For the default method, it must be coercible to a numeric matrix.
Additional arguments to image
, or the default method.
Whether to transpose the matrix before display. This is
usually necessary due to the conventions of image
.
Whether to use raster graphics if possible. This is
generally preferred for speed. Passed to image
.
Whether to add the image to an existing plot. If TRUE
,
zero values in the image will be converted to NA
s for plotting
purposes, to make them transparent. This will not affect the original
image data.
The colour scale to use. The default is 256 grey levels. The array method overrides this appropriately.
The maximum colour value for each channel. If NULL
, the
default, this is taken from the "range"
attribute, if there is one,
otherwise it is 255 for integer-mode arrays, and 1 otherwise. Passed to
rgb
.
Jon Clayden <code@clayden.org>
Relative to the defaults for image
(from the graphics
package), this function transposes and then inverts the matrix along the
y-direction, uses a grey colour scale, fills the entire device with the
image, and tries to size the image correctly given the dot pitch of the
display. Unfortunately the latter is not always possible, due to downstream
limitations.
If x
has attributes "range"
, "background"
, "asp"
or "dpi"
, these are respected.