spatstat (version 1.9-0)

im: Create a Pixel Image Object

Description

Creates an object of class "im" representing a two-dimensional pixel image.

Usage

im(mat, xcol=seq(ncol(mat)), yrow=seq(nrow(mat)), lev=levels(mat))

Arguments

mat
matrix or vector containing the pixel values of the image.
xcol
vector of $x$ coordinates for the pixels
yrow
vector of $y$ coordinates for the pixels
lev
possible factor levels, if mat should be interpreted as a factor.

Warnings

The internal representation of images is likely to change in the next release of this package.

Details

This function creates an object of class "im" representing a two-dimensional pixel image. See im.object for details of this class.

If mat is not a matrix, it will first be converted into a matrix with nrow(mat) = length(yrow) and ncol(mat) = length(xcol). Note that the row index of the matrix mat corresponds to increasing y coordinate, while the column index of mat corresponds to increasing x coordinate. Thus xrow has one entry for each row of mat and ycol has one entry for each column of mat. A correct display of the image would be obtained by transposing, e.g. image.default(xcol, yrow, t(mat)), if you wanted to do it by hand.

See Also

im.object, Kmeasure, setcov

Examples

Run this code
whitenoise <- im(matrix(rnorm(10000), 100, 100))
   image(whitenoise)

Run the code above in your browser using DataCamp Workspace