transformquantiles {spatstat.univar} | R Documentation |
Transform the Quantiles
Description
Apply a transformation to the quantiles of a vector, or to the quantiles of the pixel values in a pixel image.
Usage
transformquantiles(X, uniform = FALSE, reverse = FALSE, ...)
Arguments
X |
A numeric vector, matrix, array, or a pixel image
(object of class |
uniform |
Logical value specifying whether each quantile value should be replaced by the corresponding cumulative probability (called histogram equalisation, transformation to uniformity or probability integral transformation). |
reverse |
Logical value specifying whether to swap the upper and lower quantiles. |
... |
Ignored. |
Details
The argument X
may be a vector, matrix,
array, or a pixel image (object of class "im"
).
The algorithm will first extract the entries or pixel values of
X
as a vector, and sort the values into ascending order.
If uniform=TRUE
, the entries in this vector will be replaced by the
corresponding cumulative probabilities (the k
th
smallest value will be replaced by the
number (k-0.5)/n
where n
is the total number of values).
If reverse=TRUE
, the resulting vector will be reversed
so that it is in descending order (so that the k
th smallest
value will be swapped with the k
th largest value).
Finally the transformed values will be replaced into the original positions in the vector, matrix, array, or pixel image.
The case uniform=TRUE, reverse=FALSE
is called
transformation to uniformity, the
probability integral transformation,
histogram equalisation, or quantile transformation.
The resulting values are uniformly distributed between 0 and 1;
a histogram of the values in X
is flat.
Value
Another object of the same type as X
.
Author(s)
Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner rolfturner@posteo.net and Ege Rubak rubak@math.aau.dk.
See Also
To apply an arbitrary function f
to the pixel values in an image,
use the idiom X[] <- f(X[])
.
Examples
X <- c(3, 5, 1, 2, 4)
transformquantiles(X, reverse=TRUE)
transformquantiles(X, uniform=TRUE)
transformquantiles(X, uniform=TRUE, reverse=TRUE)