Image {EBImage} | R Documentation |
The package EBImage
uses the class Image
to store and process
images. Images are stored as multi-dimensional arrays containing the pixel
intensities. The class 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 could be either Grayscale
or Color
. In both modes, the
two first dimensions of the underlying array are understood to be the spatial
dimensions of the image. In the Grayscale
mode, the remaining dimensions
contain other images. In the the Color
mode, the third dimension contains
the red, green and blue channels of the image and the remaining dimensions contain
other images.
All methods of the package EBImage
works either with Image
objects or
multi-dimensional arrays but in the latter case, the color mode is assumed to be
Grayscale
.
Image(data, dim, colormode) as.Image(x) is.Image(x) as.raster.Image(y) colorMode(y) colorMode(y) <- value imageData(y) imageData(y) <- value getFrame(y, i, type='total') getNumberOfFrames(y, type='total')
data |
A vector or array containing the pixel intensities of an image. If missing, a default 1x1 null array is used. |
dim |
A vector containing the final dimensions of an |
colormode |
A numeric or a character string containing the color mode which could be
either |
x |
An R object. |
y |
An |
i |
A numeric. |
value |
For |
type |
A character string containing |
Depending of type
, getNumberOfFrames
returns the total number of frames contained
in the object y
or the number of renderable frames. The total number of frames is independent
of the color mode and is equal to the product of all the dimensions except the two first ones. The
number of renderable frames is equal to the total number of frames in the Grayscale
color mode
and is equal 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. If render
, the function returns the
i-th image as shown by the display
function.
Image
and as.Image
return a new Image
object.
is.Image
returns TRUE if x
is an Image
object and FALSE otherwise.
as.raster.Image
coerces an Image object to a raster object.
colorMode
returns the color mode of y
and colorMode<-
changes the color mode
of y
.
imageData
returns the array contained in an Image
object.
Oleg Sklyar, osklyar@ebi.ac.uk, 2005-2007
s1 = exp(12i*pi*seq(-1, 1, length=300)^2) y = Image(outer(Im(s1), Re(s1))) if (interactive()) display(normalize(y)) x = Image(rnorm(300*300*3),dim=c(300,300,3), colormode='Color') if (interactive()) display(x) w = matrix(seq(0, 1, len=300), nc=300, nr=300) m = abind(w, t(w), along=3) z = Image(m, colormode='Color') if (interactive()) display(normalize(z)) y = Image(c('red', 'violet', '#ff51a5', 'yellow'), dim=c(71, 71)) if (interactive()) display(y) ## colorMode example x = readImage(system.file('images', 'nuclei.tif', package='EBImage')) x = x[,,1:3] if (interactive()) display(x, title='Cell nuclei') colorMode(x)=Color if (interactive()) display(x, title='Cell nuclei in RGB')