Learn R Programming

spatstat (version 1.48-0)

density.psp: Kernel Smoothing of Line Segment Pattern

Description

Compute a kernel smoothed intensity function from a line segment pattern.

Usage

"density"(x, sigma, ..., edge=TRUE, method=c("FFT", "C", "interpreted"))

Arguments

x
Line segment pattern (object of class "psp") to be smoothed.
sigma
Standard deviation of isotropic Gaussian smoothing kernel.
...
Extra arguments passed to as.mask which determine the resolution of the resulting image.
edge
Logical flag indicating whether to apply edge correction.
method
Character string (partially matched) specifying the method of computation. Option "FFT" is the fastest, while "C" is the most accurate.

Value

A pixel image (object of class "im").

Details

This is a method for the generic function density.

A kernel estimate of the intensity of the line segment pattern is computed. The result is the convolution of the isotropic Gaussian kernel, of standard deviation sigma, with the line segments. The result is computed as follows:

  • if method="FFT", the line segments are discretised using pixellate.psp, then the Fast Fourier Transform is used to calculate the convolution. This method is the fastest, but is slightly less accurate.
  • if method="C" the exact value of the convolution at the centre of each pixel is computed analytically using C code;
  • if method="interpreted", the exact value of the convolution at the centre of each pixel is computed analytically using R code. This method is the slowest.

If edge=TRUE this result is adjusted for edge effects by dividing it by the convolution of the same Gaussian kernel with the observation window.

See Also

psp.object, im.object, density

Examples

Run this code
  L <- psp(runif(20),runif(20),runif(20),runif(20), window=owin())
  D <- density(L, sigma=0.03)
  plot(D, main="density(L)")
  plot(L, add=TRUE)

Run the code above in your browser using DataLab