Enhance Local Contrast parallelization/running on GPU/running faster anyhow

Hi all!

I found myself using the enhance local contrast tool in my pipeline and it makes a big difference in terms of ease of processing downstream from that. Since my images are quite large (something in the range of 15-20k x 15-20k pixels) it takes a small eternity to run this tool. I also noticed that only one core of my CPU is being used while it’s running.

Does someone know a way to parallelize this to the rest of my cores that are sitting and chilling otherwise? Or is there a way to accelerate this on the GPU?

Finally, I’m quite a noob in this, so have understanding if this is a noob question :upside_down_face:

1 Like

Hey @MarkoBarovic,

very good question! Short answer: AFAIK nobody has done it yet. But of course, it may make a lot of sense.

I just wanted to check how the code looks like, but couldn’t find it. So I’m calling @axtimwalde for help! :wink:
Fiji says the plugin lives in mpicbg.ij.clahe.Plugin

But that file doesn’t exist:

@axtimwalde Am I searching in the wrong place?



1 Like

The file is here:

I don’t know why Fiji gets the path wrong, maybe there’s an issue with how this information is stored in the jar file.


The naive way is to process multiple images at the same time. Which version are you using, the fast one or the slow one?


The slow one. I’m quite certain it produces more precise results at the end. I tested both…

By process multiple images at the same time you mean run multiple instances of Fiji?

Btw, I’m amazed every time by how supportive and nice this community is. The world needs more of such people! :slight_smile:

1 Like

Thanks! I am not sure what ‘more precise’ means in this context ;). So my first hunch would be to go for the fast version, which is also closer to what Zuiderveld described back in the 90s. The slow version updates the histograms while it is traveling across rows, but we could parallelize rows. I’ll see if I can find a minute to do this.

That would work with zero coding. You could also write a script that uses an ExecutorService to parallelize over several images open in the same Fiji instance, but that is a minor coding task.


Do you by chance have example code available showing how that works? :upside_down_face:

search.imagej.net is your friend in this case: here are the results for ExecutorService on GitHub.

E.g. this code should more or less demonstrate how to use it:

1 Like

I was more looking for an example where it’s shown HOW TO use it :wink: I’ll put it on the HOW TO wish list :wink:

1 Like