This function keeps pixels with certain
colors unchanged and transforms
others into grayscale.
The function is in fact a wrapper of
magick::image_transparent
, so it
uses the latter's color
and fuzz
parameters. NOTE: the function only works
for fully opaque or fully
transparent (labelled as "transparent") pixels.
image_keep_color(x, color = NULL, fuzz = 10, result = "magick")
an image read into R
by magick::image_read
.
the same
as magick::image_transparent
.
You can use 1 or more colors.
the same
as magick::image_transparent
.
However, Its length must either be 1 or the same
as color
.
if it is "magick" (default), the result is a magick image, if it is "raster", the result is a matrix.