"Sigmoidal" minimization of resampling filter haloing & blur

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: "Sigmoidal" minimization of resampling filter haloing

Post by NicolasRobidoux »

henrywho wrote:Seems sigmoidal-downsizing increases the brightness of all interpolated areas.
I'll double check, but it may simply be because in an IM more than a few days old, sigmoidal contrast is not perfectly invertible, and consequently overall brightness is affected: my experiments revealed a bug (or undesirable feature) which was fixed by Cristy on Monday (I think).
I've not seen any "global" colour drift in any of my tests. Only subpixel stuff.
Last edited by NicolasRobidoux on 2012-07-18T05:05:22-07:00, edited 1 time in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: "Sigmoidal" minimization of resampling filter haloing

Post by NicolasRobidoux »

anthony wrote:...I think I'll remove the use of the integer support sized 3 lobe lancoz in these examples.
Or add it as a separate 'resize technique'.
I agree: Focus on regular orthogonal Lanczos, ideally used with an HDRI compile (to minimize clipping between orthogonal passes).
The reason is that "sigmoidization" appears to be so good at removing offensive Lanczos jaggies that there is no need to smooth them out with EWA. They are slightly reduced with Radius3, but it's not something that jumps at you. And orthogonal Lanczos is slightly sharper, so it's a toss. I'll go for sharp.
You can keep the Radius3 examples under "if combined with another experimental method..." but my experience is that at 8,50%, my current favorite setting, the only difference is that orthogonal Lanczos is very slightly sharper. So it makes sense to skip Radius3 from this example.
-----
I wish I had time to experiment a lot (or pass it through Adam's test software) but...
Last edited by NicolasRobidoux on 2012-07-18T05:24:45-07:00, edited 1 time in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: "Sigmoidal" minimization of resampling filter haloing

Post by NicolasRobidoux »

Henry: You are enlarging the full size Nokia image 400%?
Last edited by NicolasRobidoux on 2012-07-18T05:40:39-07:00, edited 1 time in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: "Sigmoidal" minimization of resampling filter haloing

Post by NicolasRobidoux »

Henry: I enlarged the small version of the image (..._m) 400% and I see no colour drift. I think you are using a version of IM with the sigmoidal-contrast "bug".
henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: "Sigmoidal" minimization of resampling filter haloing

Post by henrywho »

NicolasRobidoux wrote:Henry: I enlarged the small version of the image (..._m) 400% and I see no colour drift. I think you are using a version of IM with the sigmoidal-contrast "bug".
I copied the wrong commands and it's now corrected. I was doing downsizing of the original version and see if this sigmoidal technique is safe for downsizing. I will test it again with the latest IM6 Q16 version.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: "Sigmoidal" minimization of resampling filter haloing

Post by NicolasRobidoux »

Henry: I think that you actually are right: It's not an overall brightness, it's that small (a few pixel wide, at most) bright colour areas are brightened.
Maybe 8,50% is too much, and we should push the contrast down to 6,50%?
Or indeed the sigmoidal should not have a midpoint at 50%, and something like 6,80% is right?
???
My earlier test images were pretty smooth. I think that's why I missed it. We're dealing with JPEG artifacts here.
Note: The above comments have to do with enlarging the smaller image (..._m) 400%.
-----
Thank you for trying downsampling. I have not yet, and it would not surprise me if it sucks.
Last edited by NicolasRobidoux on 2012-07-18T05:51:38-07:00, edited 1 time in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: "Sigmoidal" minimization of resampling filter haloing

Post by NicolasRobidoux »

anthony wrote:I am not certain if any of this is any better than the original resize!
See the new example section...
http://www.imagemagick.org/Usage/resize ... _sigmoidal
Yes? To me, the sigmoidal rose's lower "lip" looks way less jaggy/overshot, and yet it is sharper.
But I suffer from selection bias...
anthony wrote:Essentually this decreases the contrast, spreading out mid-tone greys before resizing, then removes that modification afterward.
Exactly!
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: "Sigmoidal" minimization of resampling filter haloing

Post by NicolasRobidoux »

NicolasRobidoux wrote:Henry: I think that you actually are right: It's not an overall brightness, it's that small (a few pixel wide, at most) bright colour areas are brightened.
This actually may be a side effect of negative lobes more than sigmoidal.
P.S. No it's not. The "sigmoization" process kinda "solarizes" the very bright spots. So, either I'm making it too strong, or the brights and darks need to be dealt with asymmetrically.
My guess is that 8,50% is too strong.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: "Sigmoidal" minimization of resampling filter haloing

Post by NicolasRobidoux »

If you decrease the contrast, the ugly "black overshoots" come back. So, there is a zero sum game: "solarized" whites or "overshot" blacks?
(*&^%$#@! I need to buy a gadget that color calibrates monitors!)
I personally really really dislike the "black overshoots", so it looks like I'm kinda stuck at something like 7,50%.
P.S. I slooooowly downloaded http://www.dcfever.com/phones/enlarge.php?id=7234 Turns out that the sigmoidal "solarization" of very bright details I was seeing when enlarging what I assume is a Hong Kong panorama was mostly happening in areas that are overexposed in the full size original from which the image I was re-enlarging was obtained!!! Also, some of the garish fushias and pinkish reds ... are there in the full size image!
Last edited by NicolasRobidoux on 2012-07-18T12:34:49-07:00, edited 5 times in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: "Sigmoidal" minimization of resampling filter haloing

Post by NicolasRobidoux »

Anthony: Suggestion: If you redo your discussion of this in the Examples, use 7,50%.
Also: I'm not sure what kind of screen you view your Examples site on, but it is my opinion that these enlargements are a bit on the small side to make differences clear.
Maybe you could show this?

Code: Select all

  convert rose: -filter lanczos -resize 350x rose_lanczos_srgb.png
  convert rose: -colorspace RGB -filter lanczos -resize 350x \
          -colorspace sRGB rose_lanczos_linear.png
  convert rose: -colorspace RGB +sigmoidal-contrast 7,50% \
          -filter Lanczos -resize 350x \
          -sigmoidal-contrast 7,50% -colorspace sRGB rose_lanczos_sigmoidal.png
To my eye, there is no question which one is best, even if the Mitchell results are included:

Code: Select all

    convert rose: -resize 350x rose_mitchell_srgb.png
    convert rose: -colorspace RGB -resize 350x -colorspace sRGB rose_mitchell_linear.png
Last edited by NicolasRobidoux on 2012-07-18T08:34:36-07:00, edited 9 times in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: "Sigmoidal" minimization of resampling filter haloing

Post by NicolasRobidoux »

Using the very wishy washy criterion of minimizing the maximum difference between EWA Radius 3 and regular orthogonal Lanczos 3, but checking it using 16-bit results instead of 8-bit, indeed 7,50% is better than 6,50% and 8,50%.
Oddly enough, the "quantative" result matches my eyeball.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: "Sigmoidal" minimization of resampling filter haloing

Post by NicolasRobidoux »

Anthony and Fred and Cristy: I very quickly checked the results using all combinations of the two different +contrast-sigmoidal and the two different -contrast-sigmoidal pieces of code (setting the two #ifdefs to all combinations of 0 and 1). My quick conclusion is that

Code: Select all

     double
        min = sigmoidal(contrast,1.0,0.0),
        max = sigmoidal(contrast,QuantumScale*midpoint,1.0),
        xi  = min+(double)i/MaxMap*(max-min);
      sigmoidal_map[i]=(MagickRealType) ScaleMapToQuantum(
         (MagickRealType)(MaxMap*(
             QuantumScale*midpoint-log((1-xi)/xi)/contrast) ));
is a broken +sigmoidal-contrast. On the other hand, either of the two -sigmoidal-contrast is fine: they give very close results.

I do prefer the -sigmoidal-contrast code that does not contain MagickEpsilon, in other words, I prefer the current IM bleeding edge. But if it made Fred happy to have something that behaves the way he expects when contrast=0 or close to it, I could live with the MagickEpsilon version of the -sigmoidal-contrast code.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: "Sigmoidal" minimization of resampling filter haloing

Post by NicolasRobidoux »

Having checked things carefully, regular Lanczos 3 and EWA "Radius 3" are different when my current favorite sigmoidalization, namely 7,50%, is used (through linear light).
EWA is better at avoiding jaggies on diagonal lines, but otherwise regular Lanczos is slightly sharper "the right way". In other words, if it was not for the checkerboard mode, regular Lanczos 3 would win, no question.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: "Sigmoidal" minimization of resampling filter haloing

Post by NicolasRobidoux »

@Henry: I checked downsampling with the Nokia picture and it looks like linear light wins, as usual.
henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: "Sigmoidal" minimization of resampling filter haloing

Post by henrywho »

NicolasRobidoux wrote:@Henry: I checked downsampling with the Nokia picture and it looks like linear light wins, as usual.
To me, downsampling in linear RGB with sigmoidal minimization looks much like downsampling in sRGB plus cooked highlights. I think it is better suited for upsampling.
Post Reply