CLAHE GIMP plugin

Hi! I just made a GIMP 3 plugin for CLAHE contrast at multiple scales :

Small scales bring up details while large scale increase global contrast.

Here is an example: original, CLAHE at scale 1/2 and CLAHE at scale 1/32

I hope this may be of some use, feedback welcome!

4 Likes

@Nicolas Welcome to the forum and thanks for sharing. I know there are some multiscale CLAHE papers out there. Maybe you could consider, experiment with and implement some of their findings.

1 Like

I have been using CLAHE in medical imagery thanks to its ability to “reveal” potential bad stuff. I did not know that it could be also interesting in digital photography… TIL :slight_smile:

For the curious folks, here is my implementation (with plenty of room for improvements and some limitations)

1 Like

This is something I wanted to implement in G’MIC, but couldn’t. Great job.

It’s already implemented in G’MIC, with filter : Details / Equalize Local Histogram.
Maybe not exactly the same, but very similar probably.

It basically does this:

$ gmic sp colorful +apply_tiles \"equalize 256 n 0,255\",32,32,1,50%,50% blend alpha,0.5

Thank you. It is working in GIMP 3.2.Windows. Installing NumPy was a bit tricky. But with instructions from chatGPT, I managed to do it. Thank you.

There might be some room for an additional feature: namely running CLAHE separately for each color channel. This way, you can also perform color correction at the same time.

1 Like

To be perfectly honest, I’m a little put off by the fact that you have to install NumPy and Python (which together easily weigh in at 200 Mb) just to get a local histogram equalization filter in GIMP. We’re really in the era of software bloat…

This thought isn’t directed at @Nicolas at all.

Having gotten my start in computer science by creating like 4KB demos on the Amstrad CPC in Z80 assembly language, I have to admit that it still strikes me as odd to see the monstrosities (in terms of size) resulting from the use of Python nowadays.

I guess that’s what they call “progress”! :cry:

2 Likes

It’s not the same. I get some idea though.

Hi, Nicolas

I have been very impressed by your program. However, unfortunately, installing numpy into the GIMP - Python environment is very difficult and your instruction for it does not seem effective in most cases. I suppose that you use self-build GIMP.

Therefore I have arranged your program.

This program runs using a Python virtual environment numpy installed. I have separated your program into the main process which does not use numpy and some subprocesses using another python interpreter and numpy in the virtual environment. When numpy processing is needed, the main process calls the subprocess and receives the results from them through shared memories.
Also I have internationalized it.

To use this program, users need to make the Python virtual environment numpy installed first. It is recommended to make it under the GIMP user setting directory, like $HOME/.config/GIMP/3.2 or $HOME\appData\roaming\GIMP\3.2 (in Windows) etc.

Next, users edit config.ini in the plug-in’s directory according to your virtual environment.
For example if you made it as $HOME/.config/GIMP/3.2/.venv you set the parameters in config.ini as follows.

[Python installed Directory in venv]
DIRPY;$GIMPDIR/.venv/bin

$GIMPDIR is a proxy keyword to indicate your GIMP setting directory path like $HOME/.config/GIMP/3.2.

This program is usable in Linux, Windows and Mac OS, however in Mac OS, the usable GIMP version is 3.2.4 or under. From 3.2.6, GIMP in Mac OS seems to inhibit the Pyhton plug-ins to call outer python scripts in the virtual environment as subprocess, for which I don’t know the reasons.