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

pixellate.psp

Convert Line Segment Pattern to Pixel Image


Description

Converts a line segment pattern to a pixel image by measuring the length or number of lines intersecting each pixel.

Usage

## S3 method for class 'psp'
pixellate(x, W=NULL, ..., weights = NULL,
                        what=c("length", "number"),
                        DivideByPixelArea=FALSE)

Arguments

x

Line segment pattern (object of class "psp").

W

Optional window (object of class "owin") determining the pixel resolution.

...

Optional arguments passed to as.mask to determine the pixel resolution.

weights

Optional vector of weights associated with each line segment.

what

String (partially matched) indicating whether to compute the total length of intersection (what="length", the default) or the total number of segments intersecting each pixel (what="number").

DivideByPixelArea

Logical value, indicating whether the resulting pixel values should be divided by the pixel area.

Details

This function converts a line segment pattern to a pixel image by computing, for each pixel, the total length of intersection between the pixel and the line segments. Alternatively it can count the number of line segments intersecting each pixel.

This is a method for the generic function pixellate for the class of line segment patterns.

The pixel raster is determined by W and the optional arguments .... If W is missing or NULL, it defaults to the window containing x. Then W is converted to a binary pixel mask using as.mask. The arguments ... are passed to as.mask to control the pixel resolution.

If weights are given, then the length of the intersection between line segment i and pixel j is multiplied by weights[i] before the lengths are summed for each pixel.

Value

A pixel image (object of class "im") with numeric values.

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

Use as.mask.psp if you only want to know which pixels are intersected by lines.

Examples

X <- psp(runif(10),runif(10), runif(10), runif(10), window=owin())
  plot(pixellate(X))
  plot(X, add=TRUE)
  sum(lengths_psp(X))
  sum(pixellate(X))
  plot(pixellate(X, what="n"))

spatstat.geom

Geometrical Functionality of the 'spatstat' Family

v2.1-0
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Tilman Davies [ctb], Ute Hahn [ctb], Abdollah Jalilian [ctb], Sebastian Meyer [ctb], Suman Rakshit [ctb], Dominic Schuhmacher [ctb], Rasmus Waagepetersen [ctb]
Initial release
2021-04-15

We don't support your browser anymore

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