Learn R Programming

spatstat.geom (version 3.3-2)

framedist.pixels: Distance to Bounding Frame

Description

Computes the distances from each pixel to the bounding rectangle.

Usage

framedist.pixels(w, ..., style=c("image", "matrix", "coords"))

Value

If style="image", a pixel image (object of class "im") containing the distances from each pixel in the image raster to the boundary of the window.

If style="matrix", a matrix giving the distances from each pixel in the image raster to the boundary of the window. Rows of this matrix correspond to the \(y\) coordinate and columns to the \(x\) coordinate.

If style="coords", a list with three components

x,y,z, where x,y are vectors of length \(m,n\)

giving the \(x\) and \(y\) coordinates respectively, and z is an \(m \times n\) matrix such that

z[i,j] is the distance from (x[i],y[j]) to the boundary of the window. Rows of this matrix correspond to the

\(x\) coordinate and columns to the \(y\) coordinate. This result can be plotted with persp, image

or contour.

Arguments

w

A window (object of class "owin").

...

Arguments passed to as.mask to determine the pixel resolution.

style

Character string (partially matched) determining the format of the output: either "matrix", "coords" or "image".

Author

Adrian Baddeley Adrian.Baddeley@curtin.edu.au and Rolf Turner rolfturner@posteo.net

Details

This function computes, for each pixel \(u\) in the rectangular frame Frame(w), the shortest distance to the boundary of \(Frame(w)\).

The grid of pixels is determined by the arguments "\dots" passed to as.mask. The distance from each pixel to the boundary is calculated exactly, using analytic geometry.

See Also

bdist.pixels.

Examples

Run this code
  opa <- par(mfrow=c(1,2))
  plot(framedist.pixels(letterR))
  plot(bdist.pixels(letterR))
  par(opa)

Run the code above in your browser using DataLab