as.im {spatstat}R Documentation

Convert to Pixel Image

Description

Converts various kinds of data to a pixel image

Usage

  as.im(X, W=as.mask(as.owin(X), dimyx=dimyx), ..., dimyx=NULL)

Arguments

X Data to be converted to a pixel image.
W Window object which determines the spatial domain of the image
... Additional arguments passed to X when X is a function.
dimyx Optional. Dimensions for the pixel array. An integer, or vector of 2 integers c(ny, nx).

Details

This function converts the data X into a pixel image object of class "im" (see im.object).

Currently X may be any of the following:

The spatial domain (enclosing rectangle) of the pixel image is determined by the argument W. If W is absent, the spatial domain is determined by X. When X is a function or a single numerical value, W is required.

The pixel array dimensions of the final resulting image are determined by (in priority order)

Note that if dimyx is given, this will override the pixel dimensions of X if it has them. Thus, as.im can be used to change an image's pixel dimensions.

Value

An image object of class "im".

Author(s)

Adrian Baddeley adrian@maths.uwa.edu.au http://www.maths.uwa.edu.au/~adrian/ and Rolf Turner rolf@math.unb.ca http://www.math.unb.ca/~rolf

Examples

  data(demopat)
  # window object
  W <- demopat$window
  plot(W)
  Z <- as.im(W)
  image(Z)
  # function
  Z <- as.im(function(x,y) {x^2 + y^2}, unit.square())
  image(Z)
  # function with extra arguments
  f <- function(x, y, x0, y0) {
      sqrt((x - x0)^2 + (y-y0)^2)
  }
  Z <- as.im(f, unit.square(), x0=0.5, y0=0.5)
  image(Z)
  # Revisit the Sixties
  data(letterR)
  Z <- as.im(f, letterR, x0=2.5, y0=2)
  image(Z)
  # usual convention in S
  stuff <- list(x=1:10, y=1:10, z=matrix(1:100, nrow=10))
  Z <- as.im(stuff)
  # convert to finer grid
  Z <- as.im(Z, dimyx=256)

[Package spatstat version 1.11-3 Index]