Image | R Documentation |
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
.
Image(data, dim, colormode)
as.Image(x)
is.Image(x)
## S3 method for class 'Image'
as.array(x, ...)
## S3 method for class 'Image'
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'))
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 |
colormode |
A numeric or a character string containing the color mode which can be
either |
x |
An R object. |
y |
An |
max |
Number giving the maximum of the color values range. |
i |
Number(s) of frame(s). A single number in case of |
value |
For |
type |
A character string containing |
... |
further arguments passed to or from other methods. |
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.
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.
Oleg Sklyar, osklyar@ebi.ac.uk, 2005-2007
readImage
, writeImage
, display
s1 = exp(12i*pi*seq(-1, 1, length.out=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, length.out=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')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.