image_col_numeric {plothelper} | R Documentation |
Colorize an Image according to Gray Scale
Description
A color image can be converted to one with
different degrees of gray. Then, colors in a
palette can be added according to the gray
degrees. The function is a simple wrapper
of scales::col_numeric
. The pixels
which are deliberately assigned
"transparent" in the original magick image will
always kept unchanged.
Usage
image_col_numeric(
x,
palette = c("purple", "yellow"),
n = 256,
alpha = FALSE,
result = "magick",
res = 144
)
Arguments
x |
an image
read into R by |
palette |
two or more colors. The default is c("purple", "yellow") which means the deeper colors on the image will become purple and the lighter yellow. |
n |
the max num of colors that will be used. The default is 256. Note, the number of colors that really exist may be smaller than this number. |
alpha |
whether
transparency is used. Transparency
only exists when |
result |
if it is "magick" (default), the result
is a picture of the same type used by package magick.
If it is "raster", the result is a matrix that can be
used as a raster by |
res |
resolution that is used by
|