[SOLVED] making sense of sigmoidal-contrast

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: making sense of sigmoidal-contrast

Post by NicolasRobidoux »

fmw42 wrote:...But (in concept) it should approach a straight line as contrast goes to zero. The IM function does not...
@Fred: Sigmoidal-contrast approaches a straight line as contrast goes to zero since I first started modifying the code. (Actually, if contrast<MagickEpsilon, sigmoidal-contrast is now the identity map.)
This has been the case with IM7 for more than a month. IM6 caught up a bit later (a few days ago in svn?).
In both IM6 and IM7, sigmoidal-contrast is fairly different beast than it was two months ago. At "normal" contrast values, it actually has returned to pretty much what it was before the February 2012 changes (in terms of results), except that in IM7 out of gamut HDRI values are now handled with a lighter touch (the hard clamping introduced by the use of a LUT is no more).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: [SOLVED] making sense of sigmoidal-contrast

Post by fmw42 »

Nicholas,

Is this in the current IM 6 release or in the beta or subversion? The only notes I see in the changelog goes back to

2012-08-01 6.7.8-8 Nicolas Robidoux <nicolas.robidoux@gmail...>
Clean up sigmoidal-contrast.


I will test it on my sigmoidal script once I have a released or beta version to use with your latest code.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: [SOLVED] making sense of sigmoidal-contrast

Post by NicolasRobidoux »

@Fred: It's in 6.7.9-5, which I expect be released this coming weekend (as beta? I only ever use the svn bleeding edge...).
The "clean up" was when I was figuring up what the previous version was doing, before making significant changes.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: [SOLVED] making sense of sigmoidal-contrast

Post by fmw42 »

NicolasRobidoux wrote:@Fred: It's in 6.7.9-5, which I expect be released this coming weekend (as beta? I only ever use the svn bleeding edge...).
The "clean up" was when I was figuring up what the previous version was doing, before making significant changes.
OK. I will get the beta later today and test it.

Just curious. Did you switch to tanh/atanh or leave the exponential form?
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: [SOLVED] making sense of sigmoidal-contrast

Post by NicolasRobidoux »

@Fred: The code (which predates today's modifications by Cristy and me that had to do with making it Windows compilable) is here: viewtopic.php?f=22&t=21575&start=15#p89954.
Summary: If atanh is available, it uses tanh/atanh. Otherwise, it uses the logistic sigmoidal and it's inverse. The results are the same within round off.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: [SOLVED] making sense of sigmoidal-contrast

Post by fmw42 »

NicolasRobidoux wrote:@Fred: The code (which predates today's modifications by Cristy and me that had to do with making it Windows compilable) is here: viewtopic.php?f=22&t=21575&start=15#p89954.
Summary: If atanh is available, it uses tanh/atanh. Otherwise, it uses the logistic sigmoidal and it's inverse. The results are the same within round off.
I will check with Magick to see if it is folded into the current beta and then test. It is nice to know that my suspicions about tanh/atanh being equivalent to the exponential forms are confirmed. Thanks for all your work on -sigmoidal-contrast.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: [SOLVED] making sense of sigmoidal-contrast

Post by NicolasRobidoux »

I figured out how to extend the sigmoidal curve so that we don't have to worry about out of gamut values, without clamping. (Irrelevant in current IM6 which uses LUTs, but matters in current IM7.)

Extend the curves past "black" and "white" by straight lines.

With high contrast, these straight lines will be almost horizontal. But never perfectly horizontal.

Will implement this when I have a minute.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: [SOLVED] making sense of sigmoidal-contrast

Post by anthony »

With a 'center' of 0 or 100%, that straight line will be far from 'near horizontal'.
The test and calculation would complicate the code quite a bit.

What is wrong with just using the values as normally calculated when input values are outside the normal color range. I mean you only get those values when using HDRI anyway.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: [SOLVED] making sense of sigmoidal-contrast

Post by NicolasRobidoux »

Well, it's a choice, but a number of color space transformations produce nominally out of gamut color values.
Example: Y'CbCr -> R'G'B' or RGB.
Also, it would be nice to be able to use sigmoidal-contrast or sigmoidization on images that have negative transparency and color channels, without them being clipped.
But indeed this would only ever be an issue in HDRI without LUTs.
I'm totally OK with NOT adding this. But I thought it may make some things work better, the straight lines are easy to figure out, and for almost all images, the two ifs that are involved (conditional moves, really) are easy to predict, which means that Intel chips will just eat them up.
Basically, it would make sigmoidal-contrast perfectly invertible, and it would not clamp everything and anything that is passed through +sigmoidal-contrast.
Post Reply