This library rewrite an image given as input using only two colors a la dithering. The image is separated in squares of 5x5 pixels. For each of those squares the average relative luminance is calculated. This luminance is then used to assign a level to the square. The level is between 0 and 9, 0 for completly bright and 9 fully dark. The content of the square is then filled with the following pattern (depending on the level) :
Here's a picture showing the same patterns on a bigger surface :
Finally here's an example using the painting "The swan, no 1" from Hilma af Klint :
When the third parameter is true the output will be in color, the brightest and darkest colors from the 25 pixels are used to fill the patterns showed above.
To use this library you can simply call it using :
dithor::dithor("input.jpg", "output.jpg", true, true);
It's also included in the glitched factory offering a nice gui to use it directly on your images.