Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Post by NicolasRobidoux »

Opinion: Robidoux is a good safe EWA scheme, but for enlargements I like EWA LanczosSharp more, and sigmoidizing makes it better. IMNSHO (Im My Not So Humble Opinion), sigmoidized tensor Ginseng is also really good if you want additional sharpness (and don't mind more jaggies, and a bit more haloing, than one gets with EWA LanczosSharp). For downsampling I like the sharper EWA Lanczoses better too (but stay away from sigmodization: linear light please!). But I'm still hunting for "the best" sharper EWA windowed-Jinc (although RadiusN seems to be pretty good).
An internal corporate panel of web designers chose Robidoux over LanczosSharp and several other schemes for small images and thumbnails, but they were not downsampling through linear light (my fault: I did not know at the time how important it is) and of course this was before sigmoidization (which should not be used when downsampling anyway), so this decision may be revised when I point them in the right direction? (Figuring things out is immensely time consuming: There are so many variables, down to the fact that JPEG compression has to be taken into account, and the resampling filter interacts with it.)
ASIDE:
I am starting to think that what I like/don't like in images is not the same as many people? I think my "overall impression" is skewed by my eye focusing on artifacts. I see the artifacts more than anything else! And I really really really dislike "synthetic" looks. I'd rather have lens-like blur than sharpness which comes with jaggies, pronounced halos, or a "plastic" look. (Or eye pupils that are not round.)
I actually am stunned at how many people like the SR scheme of Daniel Glasner, Shai Bagon and Michal Irani
http://www.wisdom.weizmann.ac.il/~visio ... ageSR.html, at least for images without self-similarity (when there is self-similarity or at least repeating patterns within the image, fractals/neural nets are really hard to beat).
It is starting to "look" to me like people like sharpness pretty much at the expense of anything else.
Last edited by NicolasRobidoux on 2012-08-30T06:39:20-07:00, edited 2 times in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Post by NicolasRobidoux »

@Anthony: Having Ginseng be a shortcut for using "mix and match" Sinc and Jinc (Jinc-windowed Sinc -resize and Sinc-windowed Jinc -distort resize) actually makes even more sense, given that Jinc, really, should never be used as a filter for -resize, and Sinc, really, should never be used as a filter for -distort resize. The above two "mix-and-match" are the only ones that are useable.
-----
I did not think of this earlier, but it could be that Sinc-windowing Jinc when doing EWA would allow getting a bit better sharpness without having to (de)blur.
P.S. Argh! I am totally wrong! Orthogonal Sinc-windowed Jinc may be a very good looking scheme, at least when sigmoidized!!! Of course it's not interpolatory...
P.S. @Anthony: Hold off until I figure things out better.
P.S. I was wrong about "mixing" orthogonal and EWA: To make a tensor Sinc scheme with radial windowing work, you need to have a more smoothing window radial function than usual, because the crossings of the tensor Sinc are not aligned with the crossings of the windowing function. You can't just put the two blindly together and expect something similar as what you get from the pieces. So, this becomes back back burner.
Last edited by NicolasRobidoux on 2012-08-23T04:49:59-07:00, edited 2 times in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Post by NicolasRobidoux »

OK: Orthogonal Sinc-windowed Jinc works but it's definitely not interpolatory. It would take me more time than I have really figuring out what it's good for. It works really well with sigmoidization and text, though. But it's a completely different beast than the other windowed Sincs (as should be).
Orthogonal Jinc-windowed Sinc is an incremental improvement on Lanczos. Orthogonal Sinc-windowed Jinc is something completely different. Possibly worthwhile (Mitchell replacement?). But it would take me a long time to figure out everything about it.
-----
So, I still vote for Ginseng meaning "use Sinc-windowing with Jinc (-distort resize), and Jinc-windowing with Sinc (-resize)".
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Post by NicolasRobidoux »

Warning: Sigmoidization changes the character of a scheme substantially: It makes it sharper (meaning that interfaces are less blurry), less halo-y (at least at moderate values of the contrast), and it introduces (generally invisible) colour bleed.
Whatever I say about a scheme these days has to be understood within the fact that I always use sigmoidization when enlarging (with contrast in the ballpark of 10).
I find it rather amusing that sigmoidization reduces "lens blur" while introducing "chromatic aberration".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Post by fmw42 »

I find it rather amusing that sigmoidization reduces "lens blur" while introducing "chromatic aberration".
What about sigmoidizing only the "intensity" channel and leaving the other chroma channels alone, that is resize without the sigmoidization. Such as with YCbCr or Lab or even HCL.

Perhaps linearize first with -colorspace RGB and end with -colorspace sRGB and in between convert to one of the above colorspaces, process the Y or L channel with sigmoidization and the others without, then recombine.

Just thinking out loud. It may not make any sense. I would hope that this would avoid the "chromatic aberration"?

Note that -separate now produces linear grayscale channels
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Post by NicolasRobidoux »

Fred: Applying sigmoidization only to a luminance channel is an eminently reasonable thing to try. However, there is no such thing as a perfect luminance/other things conversion, and I am concerned that something will somehow be lost in the shuffle. Every luminance ends up containing colour information.

What would eliminate it, I think, is using a locally defined sigmoidization, based on the min an max of each channel in a local patch (which will need to be smoothed out). But this is a very complicated thing to do in IM (or anywhere), and I am really not sure it will work well.

So, at this point, I'm trying to squeeze the most out of applying it to all channels (in linear RGB with sRGB primaries).
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Post by NicolasRobidoux »

Just to show what orthogonal Sinc-windowed Jinc looks like, two examples, with the same sigmoidization as the above ones for orthogonal Jinc-windowed Sinc. Code:

Code: Select all

magick input_small.png -colorspace RGB +sigmoidal-contrast 11.6933 -define filter:filter=Jinc -define filter:window=Sinc -define filter:lobes=3 -resize 300% -sigmoidal-contrast 11.6933 -colorspace sRGB SincWindowedJinc.11p6933.png
Results, both 3x (like before):
Image
Image
Definitely on the very blurry side of things, but not annoyingly so.
Last edited by NicolasRobidoux on 2012-08-24T08:48:09-07:00, edited 2 times in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Post by NicolasRobidoux »

@Anthony:
With most images, the difference between (orthogonal) Jinc-windowed Sinc and Lanczos (Sinc-windowed Sinc) is below 8 in every 8-bit sRGB channel. As a deviation from black, [8,8,8], in sRGB, is 2.3 L*a*b* JND, which is a reasonable value for the threshold of imperceptibility. Within lighter values, a deviation of 8 in all channels is more noticeable, but it does not jump at you.
No matter how I like the pun, and how much I like that it sometimes noticeably decreases haloing without an increase in jagginess (or colour separation, when using sigmoidization), it would seem that the above makes a strong case that it is not worth adding to the list of standard schemes.
It would make me happy to have it included. But I can find other ways to put a smile on my face.
-----
Now, orthogonal Sinc-windowed Jinc is interesting, but it is not an "optimal scheme".
Neither is EWA Sinc-windowed Jinc.
So, having to go through -define to get them is fine.
-----
P.S. I double checked. The difference is almost always unnoticeable. No need to add Ginseng to the standard list, unless you feel like it of course. When I program a windowed Sinc for another library, it's likely that I'll use Ginseng. But ImageMagick has enough of those already, and Lanczos is close enough.
This being said, Cosine-windowed Sinc is also really good (on the sharp/halo-y side, of course). And, well, Lanczos is smack down the middle of these two :) You can see the "sharpness/halo" going up slightly in some features as you go from Ginseng to Lanczos to Cosine-windowed Sinc (all orthogonal). You really need to scrutinize for this, though.
P.S. The "safer" contrast for Cosine-windowed Sinc is about 10.69226.
Last edited by NicolasRobidoux on 2012-08-27T09:44:16-07:00, edited 6 times in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Post by NicolasRobidoux »

Another thing: No matter how much I want to "give the masses" the sharpness they so crave, I'll stick to "safer" values of the contrast (under 10) from now on ("Do no harm.").
I'll try pushing again when contrast is done at float precision when in HDRI mode (instead of using a LUT), even though I doubt it will change much anything.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Post by NicolasRobidoux »

Although the impact. compared to Lanczos, is almost always very very small, Ginseng (orthogonal Jinc-windowed Sinc 3-lobe) manages to reduce both haloing and jaggyness, and the very very slight decrease in sharpness is actually "natural" looking (to me): Ginseng refrains from artificially increasing acutance "at the right places". Which means that its sigmoidized Ginseng is now my orthogonal scheme of choice for anything but downsampling. When downsampling, sigmoidization is a no-no, and I anyway only use EWA schemes when downsizing.
If I want sharpness at all cost, I'll use Lanczos or Cosine or even Welch (all 3-lobe). For blurry images, they are very good. I may even increase the number of lobes. (5 works well with a lot of windows. 4 could be said to be enough. 8 sometimes is great, with Parzen for example.)
But for "all purpose sharp enlargement", Ginseng is it for me.
P.S. This being said, if I want noticeably less jagginess and a bit less halo, and am willing to let go of a bit of sharpness, it's still EWA LanczosSharp (sigmoidized if upsampling) that has my favours. That is: EWA LanczosSharp is my "good looks" all purpose scheme. (Analogy: Ginseng (Jinc-windowed Sinc 3-lobe) is my Catmull-Rom of choice, EWA LanczosSharp (Elliptical Weighted Averaging slightly deblurred Jinc-windowed Jinc 3-lobe) is my Mitchell-Netravali.)
Last edited by NicolasRobidoux on 2012-08-29T12:53:57-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: Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Post by NicolasRobidoux »

@Anthony:
Sorry for the conflicting message.
It is my opinion that Ginseng should be added, and actually that it should replace Lanczos when this latter method is the default.
This would not be a huge improvement, but it is an improvement.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Post by NicolasRobidoux »

Found another source of test results, with test images with a different character: http://www.ipol.im/pub/algo/g_roussos_d ... erpolation. Pretty impressive method too, related, as far as I can tell quickly, to greycstoration http://jcornuz.wordpress.com/2008/01/04 ... storation/.
Here is sigmoidized Ginseng on the three test images:
ImageImageImage
Last edited by NicolasRobidoux on 2012-08-29T03:43:41-07:00, edited 3 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Post by fmw42 »

Perhaps I am missing something, but where did you find the original small images to enlarge?

I ran their demo on the Maxim chip image with 4x enlarging and it looks terrible -- way too jagged.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Post by NicolasRobidoux »

fmw42 wrote:Perhaps I am missing something, but where did you find the original small images to enlarge?
I had to reconstruct them from the nearest neighbour enlargements:ImageImageImage
And yes, if you go for "faithful", I think sigmoidized Ginseng does pretty well. Although, as discussed in another thread, I think I'll stick to the "safer" values of sigmoidal contrast from now on. I'll add those when I have a minute.
------
Actually, my re-enlargements are not perfectly aligned with the ones shown at the site, and this messes up PSNR big time. I'll have to dig. I suspect that my reduced versions are probably not aligned as well.
P.S. Ah ah! The originals are not aligned with the "nearest neighbour" versions shown alongside them at the site. I don't feel like taking the time to figure out what the correction is.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Sigmoidized Ginseng (pronounced "Jinc-Sinc") resampling

Post by NicolasRobidoux »

Same enlargements, this time with the "safer" contrast value 9.520945 instead of the "not quite as safe but possibly better overall" 11.6933:
ImageImageImage
You will have a hard time seeing the difference. The higher contrast value gives an image which is a tiny bit less blurry (look at the upper eyelid of the frog). I cannot see any difference in "colour bleed".
P.S. With these test images at least, I think I like the higher contrast better. Will keep comparing.
Post Reply