First Post! Question about Speed of G'MIC filters

I’m using the G’MIC plugin on Affinity Photo Windows on a decent, not awesome PC. 16MB ram, decent / recent CPU, Windows & Apps on SSD, etc.

Some of the filters are really slow, and timeout often and so on. This is with pretty large files, 4,000 x 6,000 - But these are not giant files either.

Is there any way to speed G’MIC up? What does it need, more RAM, Better Video Card, CPU, Etc?

This is the main problem. There’s no specific size that you need, but at the minimum 2 GB. I use a 56GB Ram computer. If you’re using 16 GB, then let us know which is slow, and then see if we can optimize it.

big typo there! 16gb, RAM I’ve got.

OMG 16mb ram? That’s like MacIntosh II days with the fancy 120mb disk drive.

In that case, let us know which filters are slow. Also, some filters can’t really be improved in speed due to how G’MIC work or the algorithm itself.

My settings:
Affinity 1.10.4
Gmic 3.0.0 (Affinity Plugin, not the very latest, need to update)

i5 8th gen, 8Gb RAM
And it runs reasonably fine.

Just bumped to 3.0.0.1 - still gives me 3.0.0, but I guess it will be fine.

Hello. A few remarks about this :

  • By nature, image processing algorithm are time-consuming. They actually need to process a lot of information. A 4000x6000 RGB image means 72M values, so even the most simple filter that only loops over all image pixels and do some basic operations (e.g. contrast / brightness change) must implement a loop with N millions of iterations. And that is the easiest case (algorithm complexity in O(N)).
  • Now, of course, since we don’t make only those simple stuffs in G’MIC, the algorithm complexity can be far worse (like O(N^2) or O(N^3)), actually meaning billions of operations required to process each pixel.

Usual way of optimizing stuffs in image processing are :

  • Use the GPU. Those are very specialized chips allowing hundreds/thousands of simple arithmetic operations done in parallel. Very fast, but at the same time, a pain to work with, because there are a lot of constraints that your algorithm has to deal with (e.g. memory accesses being relatively slow, so processing must remain as much local as possible). Those constraints are difficult to handle for a generic image processing toolbox as G’MIC is, so we don’t use GPUs (now) in G’MIC.

  • Use multi-threading operations with the CPUs (multi-core parallelization) : That is what is done in G’MIC for a lot of image processing operators. But here again, parallelizing an algorithm is not always possible. Some algorithms are designed to work sequentially, and for those, there is not much to do.

All in all, the filter speed depends on many parameters : resolution of the image (yes, 4000x6000 is usually considered as a large image for non-GPU-ized algorithms), complexity of the algorithm (e.g., applying simple brightness/contrast is faster than doing patch-based inpainting), etc.

The configuration of your PC is actually nice. I don’t think you’ll get more visible performances in G’MIC except if you choose the fastest possible CPUs (but this usually means buying a new machine :slight_smile: ).

EDIT I forgot a third way of optimizing stuffs for the user :

  • Get a server with zillions of GPU cards or CPUs and use it to compute the result of the filter on the user’s image. This is what Adobe done in Photoshop with their latest neural network filters. This is hardly possible for an open-source software like us (such a server has a cost), and I personnally don’t like much forcing the user to have an internet connection to apply an image processing filter (without saying things about data privacy and so on…).
2 Likes

What a thorough and informative answer David!

Much appreciated.

I don’t know about the Affinity version of GMIC, but on the windows version you can change the length of the timeout. When you start GMIC, there is a “settings” button. If you click on that, you can change the timeout. It wouln’t make it any faster, but at least it eliminate one problem.

I would like to mention that if there’s a specific filter you use a lot, sometimes the speed can be improved for larger images. I’ve had such requests in the past and was able to improve it significantly, so it might be worth asking :slight_smile: