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.
image_col_numeric(
x,
palette = c("purple", "yellow"),
n = 256,
alpha = FALSE,
result = "magick",
res = 144
)
an image
read into R by magick::image_read
.
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.
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.
whether
transparency is used. Transparency
only exists when alpha = TRUE
and your
image is in the format (e. g., png) that supports
transparency. The default is FALSE.
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 ggplot2::annotation_raster
.
resolution that is used by
magick::image_graph
. The default is 144.