title: How to use dithering to display an gray image with only black and white pixels?
body: <p>I have a 256 gray levels image, which I want to draw thanks to only #000 (black) and #FFF (white) pixels (nothing else).</p>
  
  <p>One way to do that is to use dithering : <a href="https://upload.wikimedia.org/wikipedia/commons/6/6d/Dithering_example_red_blue.png" rel="nofollow noreferrer">https://upload.wikimedia.org/wikipedia/commons/6/6d/Dithering_example_red_blue.png</a></p>
  
  <p>In such an algorithm, a sort of blur is made by increasing the number of pixels (white and black for me) in an area.</p>
  
  <p>I don't know how to implement it however : how can I determine the number of pixels to represent the required level of gray ?
  Could you please write such an algorithm (use pseudocode for example, or Java, Scala, C, C++) ?</p>