I'm searching for a way to reverse the colors of a black and white image that I have loaded into R. Consider the following example:
With the magick
package, I can load a JPEG image into R as follows:
library("magick")
picture <- image_read("path/picture.jpg")
I can also set the colors of this image to black and white:
picture <- image_quantize(picture, colorspace = "gray")
However, I didn't find a way how to reverse the colors of this image (i.e. black gets white and white gets black). How could I do that in R?
Try the `image_negate()' function.
https://cran.r-project.org/web/packages/magick/vignettes/intro.html#filters_and_effects