Floyd-Steinberg dithering (see
Wikipedia
) in Javascript
Left: original image
Center: RGB dithering. All color components are either 0 or 255 (8 possible colors total)
Right: Black and white dithering (all pixels are either white or black)