robweber / omni-epd

An EPD (electronic paper display) class abstraction to simplify communications across multiple display types.
GNU General Public License v3.0
77 stars 16 forks source link

Add dithering option #46

Closed missionfloyd closed 3 years ago

missionfloyd commented 3 years ago

Per https://github.com/TomWhitwell/SlowMovie/issues/75, this adds every dithering algorithm available in hitherdither.

[EPD]
type=omni_epd.mock

[Display]
dither=bayer
order=8
threshold=[128, 128, 128]

Valid options for dither:

floyd-steinberg and none call _filterimage(), passing the dithering mode to Pillow. The rest use hitherdither.

Hitherdither is written completely in python, so some of these can be really slow. Bayer and cluster dot are fast, but the rest can take anywhere from several seconds to several minutes, depending on resolution and colors (tested on a Raspberry Pi 4.)

Bayer, cluster-dot, and yliluoma can be fine-tuned with the order and threshold options.

Hitherdither actually accepts an order paremeter for the rest as well. It does something, but I'm not really sure what, so I've left it out for now.

robweber commented 3 years ago

This is pretty slick. I tried to test it out on my EPD and noticed one odd issue. When display() is called the _applyConfig() method is always called to change the image based on the config information. Calling _filterImage() is left up to the implementing driver classes. Some don't need it as the filtering is done in the EPD driver. BW only devices just pass the image object straight through. Any dithering effects will get bypassed in these cases.

Would it be better to use _applyConfig() to do the image manipulation or should these effects just be skipped for certain devices?

missionfloyd commented 3 years ago

Good point, I've gone ahead and done that.

robweber commented 3 years ago

You're definitely right about the amount of time some of them take - wow. I was watching usage too and it pegs the CPU (Rpi 4 as well) at 100% for quite a while. Still pretty cool to see the different effects on the same image though.

robweber commented 3 years ago

I'm going to play with this a bit more but looking pretty cool. Nice work adding this in.

robweber commented 3 years ago

Everything I tested with it worked. Interesting to compare the output between dithers using the same image. Also ran the library against SlowMovie for a bit just to confirm the base library still worked with defaults. I'm ready to merge unless you had some more changes?

missionfloyd commented 3 years ago

I don't have any other changes right now.