Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

density.psp

Kernel Smoothing of Line Segment Pattern


Description

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

Usage

## S3 method for class 'psp'
density(x, sigma, ..., weights=NULL, edge=TRUE,
                   method=c("FFT", "C", "interpreted"),
                   at=NULL)

Arguments

x

Line segment pattern (object of class "psp") to be smoothed.

sigma

Standard deviation of isotropic Gaussian smoothing kernel.

...

Extra arguments, including arguments passed to as.mask to determine the resolution of the resulting image.

weights

Optional. Numerical weights for each line segment. A numeric vector, of length equal to the number of segments in x.

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.

at

Optional. An object specifying the locations where density values should be computed. Either a window (object of class "owin") or a point pattern (object of class "ppp" or "lpp").

Details

This is the method for the generic function density for the class "psp" (line segment patterns).

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 default), 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. Accuracy can be improved by increasing pixel resolution.

  • 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.

If weights are given, then the contribution from line segment i is multiplied by the value of weights[i].

If the argument at is given, then it specifies the locations where density values should be computed.

  • If at is a window, then the window is converted to a binary mask using the arguments ..., and density values are computed at the centre of each pixel in this mask. The result is a pixel image.

  • If at is a point pattern, then density values are computed at each point location, and the result is a numeric vector.

Value

A pixel image (object of class "im") or a numeric vector.

Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner r.turner@auckland.ac.nz and Ege Rubak rubak@math.aau.dk.

See Also

Examples

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)

spatstat.core

Core Functionality of the 'spatstat' Family

v2.1-2
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Kasper Klitgaard Berthelsen [ctb], Achmad Choiruddin [ctb], Jean-Francois Coeurjolly [ctb], Ottmar Cronie [ctb], Tilman Davies [ctb], Julian Gilbey [ctb], Yongtao Guan [ctb], Ute Hahn [ctb], Kassel Hingee [ctb], Abdollah Jalilian [ctb], Marie-Colette van Lieshout [ctb], Greg McSwiggan [ctb], Tuomas Rajala [ctb], Suman Rakshit [ctb], Dominic Schuhmacher [ctb], Rasmus Plenge Waagepetersen [ctb], Hangsheng Wang [ctb]
Initial release
2021-04-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.