spatstat.geom (version 2.1-0) S3 Group Generic methods for images


These are group generic methods for images of class "im", which allows for usual mathematical functions and operators to be applied directly to images. See Details for a list of implemented functions.


## S3 methods for group generics have prototypes:
Math(x, \dots)
Ops(e1, e2)
Summary(\dots, na.rm=FALSE, drop=TRUE)


x, z, e1, e2

objects of class "im".

further arguments passed to methods.


Logical values specifying whether missing values should be removed. This will happen if either na.rm=TRUE or drop=TRUE. See Details.


Below is a list of mathematical functions and operators which are defined for images. Not all functions will make sense for all types of images. For example, none of the functions in the "Math" group make sense for character-valued images. Note that the "Ops" group methods are implemented using, which tries to harmonise images via if they aren't compatible to begin with.

  1. Group "Math":

    • abs, sign, sqrt, floor, ceiling, trunc, round, signif

    • exp, log, expm1, log1p, cos, sin, tan, cospi, sinpi, tanpi, acos, asin, atan

      cosh, sinh, tanh, acosh, asinh, atanh

    • lgamma, gamma, digamma, trigamma

    • cumsum, cumprod, cummax, cummin

  2. Group "Ops":

    • "+", "-", "*", "/", "^", "%%", "%/%"

    • "&", "|", "!"

    • "==", "!=", "<", "<=", ">=", ">"

  3. Group "Summary":

    • all, any

    • sum, prod

    • min, max

    • range

  4. Group "Complex":

    • Arg, Conj, Im, Mod, Re

For the Summary group, the generic has an argument na.rm=FALSE, but for pixel images it makes sense to set na.rm=TRUE so that pixels outside the domain of the image are ignored. To enable this, we added the argument drop. Pixel values that are NA are removed if drop=TRUE or if na.rm=TRUE.

For the Ops group, one of the arguments is permitted to be a single atomic value instead of an image.

See Also for evaluating expressions involving images.


  ## Convert gradient values to angle of inclination:
  V <- atan(bei.extra$grad) * 180/pi
  ## Make logical image which is TRUE when heat equals 'Moderate': 
  A <- (gorillas.extra$heat == "Moderate")
  ## Summary:
  ## Complex:
  Z <- exp(1 + V * 1i)
# }