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

mean.im

Mean and Median of Pixel Values in an Image


Description

Calculates the mean or median of the pixel values in a pixel image.

Usage

## S3 method for class 'im'
## mean(x, trim=0, na.rm=TRUE, ...) 

## S3 method for class 'im'
## median(x, na.rm=TRUE)        [R < 3.4.0]
## median(x, na.rm=TRUE, ...)   [R >= 3.4.0]

Arguments

x

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

na.rm

Logical value indicating whether NA values should be stripped before the computation proceeds.

trim

The fraction (0 to 0.5) of pixel values to be trimmed from each end of their range, before the mean is computed.

...

Ignored.

Details

These functions calculate the mean and median of the pixel values in the image x.

An object of class "im" describes a pixel image. See im.object) for details of this class.

The function mean.im is a method for the generic function mean for the class "im". Similarly median.im is a method for the generic median.

If the image x is logical-valued, the mean value of x is the fraction of pixels that have the value TRUE. The median is not defined.

If the image x is factor-valued, then the mean of x is the mean of the integer codes of the pixel values. The median is are not defined.

Other mathematical operations on images are supported by Math.im, Summary.im and Complex.im.

Other information about an image can be obtained using summary.im or quantile.im.

Value

A single number.

Author(s)

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

See Also

Math.im for other operations.

Generics and default methods: mean, median.

Examples

X <- as.im(function(x,y) {x^2}, unit.square())
  mean(X)
  median(X)
  mean(X, trim=0.05)

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.