Sigmoidal contrast for gimp
Hi folks,
here is another small plugin for gimp: sigmoidal contrast.
But wait, there is already a contrast tool in gimp, why another one?
Well, the contrast tool in gimp is linear, this sigmoidal contrast is non-linear and this gives several benefits.
First when you increase contrast, dark grey values get darker but not black (at least as long as you don't get into the limitations of 8bit). The same with bright grey values, they get brighter but not white. Second when you decrease contrast, black remains black and white remains white. You can verify this easily by starting with a blank image and adding a linear gradient from black to white to it. Then just look at the behaviour of the gimp contrast and of this sigmoidal contrast.
There are several sigmoidal contrast implementations, but I couldn't find one which really treats the threshold right and allows negative values for the amount. If you know such an implementation, please let me know, I would like to compare it to my approach.
You can achieve the same behaviour with a s-shaped curve, however pulling sliders is somewhat simpler and may be used in scripts. Furthermore this plugin computes internally with 32 bit (input and output are limited to 8 bit), so I hope this will reduce artifacts.
Drop me a line if you like it.
greets mike
| Attachment | Size |
|---|---|
| sigmoidal-win32.7z | 319.99 KB |
| sigmoidal-linux32.7z | 8.4 KB |
| sigmoidal-linux64.7z | 8.09 KB |


Comments
Here's the algorithm
I wrote out a couple of formulations of the sigmoidal contrast algorithm while working on enhancing ImageMagick, one for enhancing and one for decreasing contrast:
http://osdir.com/ml/video.image-magick.devel/2005-04/msg00006.html
How would I put this in a batch?
Hi Mike,
works great!
How would I put this into a batch file?
What I tried was:
(define (sigmoidcontrast filename
contrast
threshold
visible)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename
filename)))
(drawable (car (gimp-image-get-active-layer image))))
(plug-in-python_fu_mm_extern_sigmoidal RUN-NONINTERACTIVE
image drawable contrast threshold visible)
(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image)))
But if I run this, I get the following error message:
> gimp -i -b '(sigmoidcontrast "/tmp/test.png" 13 0.5 0)' -b '(gimp-quit 0)'
Use input contrast threshold(0.01-0.99) output
(gimp:9298): LibGimpBase-WARNING **: gimp: gimp_wire_read(): error
batch command experienced an execution error
What am I doing wrong? Do the parameters not get passed correctly to the plugin?
Cheers,
Rainer
Re: Batch
Hi Rainer,
actually I haven't used gimp for batch processing so I cannot help you directly and my current spare time goes to another plugin which I plan to release this weekend.
But maybe I can help a little bit; first, the error message you show is printed if the command line program "sigmoidal" is called with the wrong number of arguments.
Second, it is a command line program itself which can read and write tiff files, so you can use it directly for a batch run with a shell script via
"sigmoidal input.tiff contrast threshold output.tiff" (replacing with your values).
Sorry, that I cannot help more at this stage. If you have further questions you can also contact me via email (see contact page) if you wish.
greets mike
Details
Hi, thanks for this contrast function, it works fine. Could you please share an algorithm details or source, or it will remain closed?
Hi "guest", this and other
Hi "guest",
this and other filters are part of dlRaw and will be released with it, once it is final. You can speed this up by helping with the development. If you have your own project, you may contact me via email, maybe we can collaborate.
However, anonymously asking for favours is not what I like.
greets mike
libtiff
On gimp startup, I get:
/home/jsack/.gimp-2.6/plug-ins/sigmoidal: error while loading shared libraries: libtiff.so.4: cannot open shared object file: No such file or directory
Despite the load error, I can find and execute the filter, but it produces no visible effect (and spits out the same error message on stderr).
On my F12, I have libtiff at
/usr/lib64/libtiff.so.3.9.2
The page at
http://www.remotesensing.org/libtiff/
says curent is 3.9.2 and develop. is 4.0.0beta5
I tried creating a symlink libtiff.so.4 (to the existing older version) and that makes it work!
Regards,
~jim
Thanks Jim for your report. I
Thanks Jim for your report. I use it with Ubuntu on 32bit and 64 bit and it worked right out of the box just with libtiff installed.
Hopefully your report helps some people to get it to work.
greets mike
libtiff?
I haven't run it yet, because the x64 version seems to require a development version on libtiff. Is that really necessary?

~jim
Hi Jim, actually it should
Hi Jim,
actually it should work with just libtiff installed, the dev package should not be needed.
greets mike
Post new comment