I enjoy the artistic possibilities of this algorithm. The attached source code renders all grayscale images in real-time, so for a better understanding of this algorithm, load up the sample code and rapidly scroll between different numbers of gray shades.
Method 7 - Custom # of gray shades with dithering (in this example, horizontal error-diffusion dithering)