@selva I wrote a program to do it. the method is called dithering, this particular type of dither is the Floyd-Steinburg dither. the src for my program is here https://github.com/pard68/miscellanea/tree/master/dither
pard68/miscellanea

A miscellaneous collection of different things. Contribute to pard68/miscellanea development by creating an account on GitHub.