I'm working on image pre-processing in R, and for that I use the package magick
. While doing my work I encountered myself in a situation that I'm unable to solve.
I've an image which consists mostly in green tones, but there are some elemnts that are in black, and those are the one which I want.
The main question is: Is there a way to use magick
to remove everything that's not black?
For example, I've a (fake) brazilian identity card signature in the image below. And I just want the signature, without the background.
I ran the code below on the image above.
library(magick)
assinatura = img %>%
image_crop("4000x100+20+210")
assinatura
The result of the code is this one.