bdist.pixels
From spatstat v1.9-2
by Adrian Baddeley
Distance to Boundary of Window
Computes the distances from each pixel in a window to the boundary of the window.
Usage
bdist.pixels(w, ..., coords=TRUE)
Arguments
- w
- A window (object of class
"owin"
). - ...
- Arguments passed to
as.mask
to determine the pixel resolution. - coords
- Logical: if
TRUE
, the result can be displayed usingpersp
,contour
etc.
Details
This function computes, for each pixel $u$
in the window w
, the shortest distance
$d(u, W^c)$ from $u$
to the boundary of $W$.
If the window is not of type "mask"
then it is first
converted to that type. The arguments "..."
are
passed to as.mask
to determine the pixel resolution.
Value
- If
coords
is false, 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. Ifcoords
is true, a list with three componentsx,y,z
, wherex,y
are vectors of length $m,n$ giving the $x$ and $y$ coordinates respectively, andz
is an $m \times n$ matrix such thatz[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 withpersp
,image
orcontour
.
See Also
Examples
u <- owin(c(0,1),c(0,1))
d <- bdist.pixels(u, eps=0.01)
image(d)
d <- bdist.pixels(u, eps=0.01, coords=FALSE)
mean(d >= 0.1)
# value is approx (1 - 2 * 0.1)^2 = 0.64
Community examples
Looks like there are no examples yet.