So I have a couple of images of logos in a rasterized format (png, no vectors).
I want to convert them to black and white with no grayscale. i.e. binary either a full black (0,0,0) or a full white (255, 255, 255).
The issue is that I do not want to just pick a cutoff threshold and set everything above to white and everything below to black.
Instead I want it to alternate colors.
For example with the lego logo I want to convert it from this
to this
But I am having a hard time finding any form of algorithm that does the job.
Is there any suitable algorithm for this?
bonus points if there is a decent implementation of it on npm