as.im

0th

Percentile

Convert to Pixel Image

Converts various kinds of data to a pixel image

Keywords
spatial
Usage
as.im(X, W, ...)
Arguments
X
Data to be converted to a pixel image.
W
Window object required when X is a function.
...
Additional arguments passed to X when X is a function.
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:

  • a pixel image object, of class"im". This object is just returned.
  • a window object, of class"owin"(seeowin.object). This window is first converted to a binary image mask byas.mask. Then the pixel entriesTRUEandFALSEare converted to1andNArespectively. The result is returned as an object of class"im".
  • a function of the formfunction(x, y, ...)which is to be evaluated to yield the image pixel values. In this case, the additional argumentWmust be a window object. This window will be converted to a binary image mask. Then the functionXwill be evaluated in the formX(x, y, ...)wherexandyarevectorscontaining the$x$and$y$coordinates of all the pixels in the image mask. This must return a numeric vector of the same length as the input vectors, giving the pixel values.
  • a single numerical value. The result is an image with pixel entries equal to this numerical value inside the imagewin.

Value

  • An image object of class "im".

Aliases
  • as.im
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)
Documentation reproduced from package spatstat, version 1.7-11, License: GPL version 2 or newer

Community examples

Looks like there are no examples yet.