Learn R Programming

spatstat (version 1.48-0)

as.matrix.im: Convert Pixel Image to Matrix or Array

Description

Converts a pixel image to a matrix or an array.

Usage

"as.matrix"(x, ...) "as.array"(x, ...)

Arguments

x
A pixel image (object of class "im").
...
See below.

Value

A matrix or array.

Details

The function as.matrix.im converts the pixel image x into a matrix containing the pixel values. It is handy when you want to extract a summary of the pixel values. See the Examples. The function as.array.im converts the pixel image to an array. By default this is a three-dimensional array of dimension $n$ by $m$ by $1$. If the extra arguments ... are given, they will be passed to array, and they may change the dimensions of the array.

See Also

as.matrix.owin

Examples

Run this code
   # artificial image
   Z <- setcov(square(1))

   M <- as.matrix(Z)

   median(M)
   
   ## Not run: 
#    # plot the cumulative distribution function of pixel values
#    plot(ecdf(as.matrix(Z)))
#    ## End(Not run)

Run the code above in your browser using DataLab