Image

0th

Percentile

Image class

EBImage uses the Image class to store and process images. Images are stored as multi-dimensional arrays containing the pixel intensities. Image extends the base class array and uses the colormode slot to store how the color information of the multi-dimensional data is handled.

The colormode slot can be either Grayscale or Color. In either mode, the first two dimensions of the underlying array are understood to be the spatial dimensions of the image. In the Grayscale mode the remaining dimensions contain other image frames. In the Color mode, the third dimension contains color channels of the image, while higher dimensions contain image frames. The number of channels is not limited and can be any number >= 1; these can be, for instance, the red, green, blue and, possibly, alpha channel. Note that grayscale images containing an alpha channel are stored with colormode=Color. All methods from the EBImage package work either with Image objects or multi-dimensional arrays. In the latter case, the color mode is assumed to be Grayscale.

Usage
Image(data, dim, colormode) as.Image(x) is.Image(x)
"as.array"(x, ...) "as.raster"(x, max = 1, i = 1L, ...)
colorMode(y) colorMode(y) <- value
imageData(y) imageData(y) <- value
getFrame(y, i, type = c('total', 'render')) getFrames(y, i, type = c('total', 'render')) numberOfFrames(y, type = c('total', 'render'))
Arguments
data
A vector or array containing the pixel intensities of an image. If missing, the default 1x1 zero-filled array is used.
dim
A vector containing the final dimensions of an Image object. If missing, equals to dim(data).
colormode
A numeric or a character string containing the color mode which can be either Grayscale or Color. If missing, equals to Grayscale.
x
An R object.
y
An Image object or an array.
max
Number giving the maximum of the color values range.
i
Number(s) of frame(s). A single number in case of getFrame, or a vector of frame numbers for getFrames. If missing all frames are returned.
value
For colorMode, a numeric or a character string containing the color mode which can be either Grayscale or Color. For imageData, an Image object or an array.
type
A character string containing total or render. Default is total.
...
further arguments passed to or from other methods.
Details

Depending on type, numberOfFrames returns the total number of frames contained in the object y or the number of rendered frames. The total number of frames is independent of the color mode and equals to the product of all the dimensions except the two first ones. The number of rendered frames is equal to the total number of frames in the Grayscale color mode, or to the product of all the dimensions except the three first ones in the Color color mode.

getFrame returns the i-th frame contained in the image y. If type is total, the function is unaware of the color mode and returns an xy-plane. For type=render, the function returns the i-th image as shown by the display function.

Value

Image and as.Image return a new Image object.is.Image returns TRUE if x is an Image object and FALSE otherwise.as.raster coerces an Image object to its raster representation. For stacked images the i-th frame is returned (by default the first one).colorMode returns the color mode of y and colorMode<- changes the color mode of y.imageData returns the array contained in an Image object.

See Also

readImage, writeImage, display

Aliases
  • Image
  • Image-class
  • Grayscale
  • Color
  • is.Image
  • as.Image
  • as.array.Image
  • as.raster.Image
  • print.Image
  • median.Image
  • quantile.Image
  • colorMode
  • colorMode<-
  • getFrame
  • getFrames
  • numberOfFrames
  • imageData
  • imageData<-
  • colormode
  • Ops,Image,Image-method
  • Ops,numeric,Image-method
  • Ops,Image,numeric-method
  • Math2,Image-method
  • [,Image,ANY,ANY,ANY-method
  • [,Image-method
  • show,Image-method
  • image,Image-method
  • hist,Image-method
  • log,Image-method
Examples
  s1 = exp(12i*pi*seq(-1, 1, length=300)^2)
  y = Image(outer(Im(s1), Re(s1)))
  display(normalize(y))

  x = Image(rnorm(300*300*3),dim=c(300,300,3), colormode='Color')
  display(x)

  w = matrix(seq(0, 1, len=300), nc=300, nr=300)
  m = abind::abind(w, t(w), along=3)
  z = Image(m, colormode='Color')
  display(normalize(z))

  y = Image(matrix(c('red', 'violet', '#ff51a5', 'yellow'), nrow=10, ncol=10))
  display(y, interpolate=FALSE)

  ## colorMode example
  x = readImage(system.file('images', 'nuclei.tif', package='EBImage'))
  x = x[,,1:3]
  display(x, title='Cell nuclei')
  colorMode(x) = Color
  display(x, title='Cell nuclei in RGB')
Documentation reproduced from package EBImage, version 4.14.2, License: LGPL

Community examples

Looks like there are no examples yet.