I then figured a quick and dirty way of doing something basically equivalent by exploiting sRGB (which is "half the inverse of a sigmoidal"): tag the sRGB image as RGB, convert to sRGB (again!), negate, tag as RGB, convert to sRGB (yet again!), resample, and then undo all operations except resampling. Basically, this is doing the resampling through a "colorspace" in which dark and light values are farther from each other.
Here is the code when the input image (the built in ImageMagick rose image) is treated as being sRGB (if not, just convert to sRGB first, for another conversion), using a bleeding edge ImageMagick 7 (results obtained with an HDRI version):
Code: Select all
magick rose: -set colorspace RGB -depth 16 -colorspace sRGB -negate -set colorspace RGB -colorspace sRGB -filter lanczos -resize 800x -colorspace RGB -negate -set colorspace sRGB -colorspace RGB -set colorspace sRGB lanczosKindaSigmoidal.png
Let's compare with "straight" lanczos, obtained with
Code: Select all
magick rose: -depth 16 -filter lanczos -resize 800x -set colorspace sRGB lanczos.png
and compare with "linear light" lanczos, obtained with
Code: Select all
magick rose: -set colorspace sRGB -depth 16 -colorspace RGB -filter lanczos -resize 800x -colorspace sRGB lanczosLinear.png
Neat, eh? (To truly appreciate, you must download the images and view them by flipping between them in a decent viewer, like nip2.)
-----
Not sure by any means that there is no zero sum game going on here---I'm particularly concerned with colour drift, which should be controlled by ensuring perfect reversibility of the non-resampling operations---and I would expect that tweaking things so that the amount and "shape" of "sigmoidation" is just right for the given filter would help things, but for a quick and dirty hack, it looks promising.
I also tried it with the curios image from the 16bit840x840images test bank, and it seemed to help there as well.
As Henry HO indirectly mentioned, you can apply only one side of the "stretch the values near black and white" if you only want to reduce one type of halo.
At some point, I'll look into using a "true" sigmoidal transform (as Fred Weinhaus suggested).