Method to plot spatially calibrated image arrays

# S3 method for im3d
image(
  x,
  xlim = NULL,
  ylim = NULL,
  zlim = NULL,
  plotdims = NULL,
  flipdims = "y",
  filled.contour = FALSE,
  asp = 1,
  axes = FALSE,
  xlab = NULL,
  ylab = NULL,
  nlevels = 20,
  levels = pretty(zlim, nlevels + 1),
  color.palette = colorRampPalette(c("navy", "cyan", "yellow", "red")),
  col = color.palette(length(levels) - 1),
  useRaster = NULL,
  ...
)

Arguments

x

The im3d object containing the data to be plotted (NAs are allowed).

xlim, ylim

ranges for the plotted x and y values, defaulting to the BoundingBox of x.

zlim

the minimum and maximum z values for which colors should be plotted, defaulting to the range of the finite values of z. Each of the given colors will be used to color an equispaced interval of this range. The midpoints of the intervals cover the range, so that values just outside the range will be plotted.

plotdims

Which dimensions of 3D im3d object to plot (character vector). Defaults to c('x','y')

flipdims

Which dimensions to flip (character vector). Defaults to flipping y.

filled.contour

Whether to use a filled.contour plot instead of a regular image plot.

asp

Whether to have a a square aspect ratio (logical, default: FALSE)

axes

Whether to plot axes (default: FALSE)

xlab, ylab

each a character string giving the labels for the x and y axis. Default to the ‘call names’ of x or y, or to "" if these were unspecified.

nlevels

The number of colour levels in z

levels

The levels at which to break z values

color.palette

The colour palette from which col will be selected.

col

a list of colors such as that generated by rainbow, heat.colors, topo.colors, terrain.colors or similar functions.

useRaster

Whether to use rasterImage to plot images as a bitmap (much faster for large images). default useRaster=NULL checks dev.capabilities to see if raster images are supported.

...

graphical parameters for plot or image may also be passed as arguments to this function.

Value

A list with elements:

  • zlim The z (intensity limits)

  • nlevels.actual The actual number of plotted levels

  • nlevels.orig The requested number of plotted levels

  • levels The chosen levels

  • colors A character vector of colours

Examples

if (FALSE) {
LHMask=read.im3d(system.file('tests/testthat/testdata/nrrd/LHMask.nrrd',package='nat'))
image(imslice(LHMask,10), asp=TRUE)
# useRaster is appreciably quicker in most cases
image(imslice(LHMask,10), asp=TRUE, useRaster=TRUE)
}