color manipulation flex

library(magick)
## Linking to ImageMagick 6.9.12.3
## Enabled features: cairo, fontconfig, freetype, heic, lcms, pango, raw, rsvg, webp
## Disabled features: fftw, ghostscript, x11
magick::image_read("pooh_and_friends.png") %>% 
  magick::image_rotate(90)

pooh <- png::readPNG(source = "pooh_and_friends.png")

str(pooh)
##  num [1:2328, 1:1233, 1:4] 0.749 0.749 0.749 0.749 0.749 ...
pooh[,,1][pooh[,,1] >.3  ] <- 1 #red
pooh[,,2][pooh[,,1] >.3  ] <- 1 #green
pooh[,,3][pooh[,,1] >.3  ] <- 1 #blue
pooh[,,4] <- 1 # alpha

# RGB

png::writePNG(pooh, "pooh_and_friends2.png")

magick::image_read("pooh_and_friends2.png") %>% 
  magick::image_rotate(90)