Click here to Skip to main content
15,868,128 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've implemented color dithering in GFX for IoT devices for color e-paper display drivers. (Arduino) This way you can virtualize, for example - a 16-bit RGB pixel over a 7-color display.

The trouble with it is it's very slow. I implemented it for a 600x448 7-color display and each frame takes over a minute to render.

I've tried caching some of the operation using a hashtable but it's not helping much if at all.

Do any of you know of any *color* dithering code out there that will work with modest CPU and RAM requirements?

hopefully it does not make extensive use of the standard template library.

I'm bound and determined to speed this up, but I'm out of my depth.

What I have tried:

I've got an existing algorithm, but it has been nearly a year since I implemented it and I don't remember what it's based on. The code is sort of lengthy to post here. I just need something faster.

Code starts at line 573 here
gfx_demo/gfx_palette.hpp at master · codewitch-honey-crisis/gfx_demo · GitHub[^]

Tables are declared here:
gfx_demo/gfx_palette.cpp at master · codewitch-honey-crisis/gfx_demo · GitHub[^]
Posted
Updated 16-Mar-22 22:29pm
v2
Comments
Patrice T 16-Mar-22 14:10pm    
Can see the algorithm code?
Just to make us know what you did.
honey the codewitch 16-Mar-22 14:19pm    
Starting at line 573 here
https://github.com/codewitch-honey-crisis/gfx_demo/blob/master/lib/gfx/include/gfx_palette.hpp

the tables are here: https://github.com/codewitch-honey-crisis/gfx_demo/blob/master/lib/gfx/src/gfx_palette.cpp

I'm using "mixing_plan_fast" although I have two.

Sorry for the length and interdependencies. This code is not really user friendly.
Greg Utas 16-Mar-22 16:28pm    
I know nothing about this topic but noticed you have several divisions by 64 in a nested for loop. If the compiler doesn't generate >> 6 for these, it would help to do that yourself.
honey the codewitch 16-Mar-22 18:12pm    
Yeah unfortunately optimizations like this won't take my minute down to seconds, which is what I need. I need orders of magnitude of performance improvement.
Shao Voon Wong 17-Mar-22 3:13am    
Using float conversion is actually faster than pure integer for computation. Not sure if it applies to embedded code. See the link below.

https://codingtidbit.com/2020/03/01/optimization-turns-out-to-be-pessimization/

1 solution

I did it! It's now acceptably performing.

I created a hashtable class, and then used that to cache my mixing plan outputs.

The best part is I did not need to change the GFX code at all, only the e-paper driver that dithers.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900