solutionset: Evaluate Logical Expression Involving Pixel Images and Return...

View source: R/levelset.R

solutionsetR Documentation

Evaluate Logical Expression Involving Pixel Images and Return Region Where Expression is True

Description

Given a logical expression involving one or more pixel images, find all pixels where the expression is true, and assemble these pixels into a window.

Usage

  solutionset(..., envir)

Arguments

...

An expression in the R language, involving one or more pixel images.

envir

Optional. The environment in which to evaluate the expression.

Details

Given a logical expression involving one or more pixel images, this function will find all pixels where the expression is true, and assemble these pixels into a spatial window.

Pixel images in spatstat are represented by objects of class "im" (see im.object). These are essentially matrices of pixel values, with extra attributes recording the pixel dimensions, etc.

Suppose X is a pixel image. Then solutionset(abs(X) > 3) will find all the pixels in X for which the pixel value is greater than 3 in absolute value, and return a window containing all these pixels.

If X and Y are two pixel images, solutionset(X > Y) will find all pixels for which the pixel value of X is greater than the corresponding pixel value of Y, and return a window containing these pixels.

In general, ... can be any logical expression involving pixel images.

The code first tries to evaluate the expression using eval.im. This is successful if the expression involves only (a) the names of pixel images, (b) scalar constants, and (c) functions which are vectorised. There must be at least one pixel image in the expression. The expression expr must be vectorised. See the Examples.

If this is unsuccessful, the code then tries to evaluate the expression using pixel arithmetic. This is successful if all the arithmetic operations in the expression are listed in Math.im.

Value

A spatial window (object of class "owin", see owin.object).

Author(s)

\adrian

and \rolf

See Also

im.object, owin.object, eval.im, levelset

Examples

  # test images
  X <- as.im(function(x,y) { x^2 - y^2 }, unit.square())
  Y <- as.im(function(x,y) { 3 * x + y  - 1}, unit.square())

  W <- solutionset(abs(X) > 0.1)
  W <- solutionset(X > Y)
  W <- solutionset(X + Y >= 1)

  area(solutionset(X < Y))

  solutionset(distmap(cells) < 0.05)

spatstat.geom documentation built on Sept. 18, 2024, 9:08 a.m.