Grey-scale images on monochrome displays

I have experimented a little today with displaying greyscale image on a 2.7" 176x264 pixel ePaper display using Floyd Steinberg dithering.

It works well on ePaper displays, there follows some screenshots (each image is 176x264 pixels):

  1. Top left is the classic image processing picture of Lena Söderberg in 8 bit grey-scale (255 levels + black)
  2. Top right is an image using a simple threshold of 128 (pixels with grey-scale value less than128 = black)
  3. Bottom left is using the dithering, all pixels are black or white but the eye averages the density
  4. Bottom right is an experimental algorithm with contrast stretching

Sketch to follow (only uses drawPixel) when I have made it more presentable!

This is a test pattern showing how the dot density changes compared with a grey-scale image on the right, there are some artifacts that more sophisticated approaches eliminate.

The key function is embedded in a library example here.

To avoid multiple passes through the image the function uses line buffers so a processor board with at least (3*width) bytes is needed. The example also uses SPIFFS on an ESP8266 so some small adaptions would be needed to use an SD library for image storage. The 8 bit images in BMP format use a colour lookup table so that uses up to 256bytes more RAM. A Mega or Due would cope OK.

A bug has been fixed in Githib.

More tests have been done to verify the colour lookup is working correctly (first Lena test image by "luck" had a 1:1 correspondence between the grey level and the index!). The rendered image contrast has improved compared to post #1 due to an earlier bug fix.