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

nearestValue

Image of Nearest Defined Pixel Value


Description

Given a pixel image defined on a subset of a rectangle, this function assigns a value to every pixel in the rectangle, by looking up the value of the nearest pixel that has a value.

Usage

nearestValue(X)

Arguments

X

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

Details

A pixel image in spatstat is always stored on a rectangular grid of pixels, but its value may be NA on some pixels, indicating that the image is not defined at those pixels.

This function assigns a value to every pixel in the rectangular grid. For each pixel a in the grid, if the value of X is not defined at a, the function finds the nearest other pixel b at which the value of X is defined, and takes the pixel value at b as the new pixel value at a.

Value

Another image of the same kind as X.

Author(s)

See Also

Examples

X <- as.im(function(x,y) { x + y }, letterR)
  Y <- nearestValue(X)
  plot(solist("X"=X,"nearestValue(X)"=Y), main="", panel.end=letterR)

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.