transformquantiles | R Documentation |
Apply a transformation to the quantiles of a vector, or to the quantiles of the pixel values in a pixel image.
transformquantiles(X, uniform = FALSE, reverse = FALSE, ...)
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. |
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.
Another object of the same type as X
.
.
To apply an arbitrary function f
to the pixel values in an image,
use the idiom X[] <- f(X[])
,
or use eval.im
.
X <- c(3, 5, 1, 2, 4)
transformquantiles(X, reverse=TRUE)
transformquantiles(X, uniform=TRUE)
transformquantiles(X, uniform=TRUE, reverse=TRUE)
Z <- 100 * as.im(bei.extra$grad, dimyx=c(25,50))
opa <- par(mfrow=c(2,2))
plot(Z,main="original")
plot(transformquantiles(Z, reverse=TRUE), main="reverse=TRUE")
plot(transformquantiles(Z, uniform=TRUE),
main="uniform=TRUE", col=grey.colors,zlim=c(0,1))
plot(transformquantiles(Z, uniform=TRUE, reverse=TRUE),
main="uniform=TRUE, reverse=TRUE",
col=grey.colors, zlim=c(0,1))
par(opa)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.