sigmoidized EWA LanczosRadius3 ... and tensor Quadratic

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

sigmoidized EWA LanczosRadius3 ... and tensor Quadratic

Post by NicolasRobidoux »

I'm on somewhat flimsy grounds RE: LanczosRadius3 being an "optimized" EWA filter, but nonetheless I'll show, in this thread, the results of the "usual" sequence of test enlargements shown for the sigmoidized Ginseng tensor method in viewtopic.php?f=22&t=21804 and with the sigmoidized EWA LanczosSharp method in viewtopic.php?f=1&t=21695#p89810. LanczosRadius3 is the best "sharp" EWA Lanczos I have now.
P.S. If one wanted to describe the LanczosRadius3 EWA scheme using an "optimization" principle, one could say that the (de)blur is the largest one which produces an EWA windowed Jinc scheme with a stencil which is never larger than for tensor Lanczos 3.
Last edited by NicolasRobidoux on 2012-09-16T13:11:06-07:00, edited 3 times in total.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: sigmoidized EWA (-distort resize) LanczosRadius3

Post by NicolasRobidoux »

The "safer" contrast value for this filter (which, as mentioned elsewhere, may not be quite as safe as should be) is about 9.9747, so the key command is

Code: Select all

magick input_small.png -colorspace RGB +sigmoidal-contrast 9.9747 -filter Lanczos -define filter:blur=.9264075766146068 -distort resize 800% -sigmoidal-contrast 9.9747 -colorspace sRGB LanczosRadius3.9p9747.png
Last edited by NicolasRobidoux on 2012-09-12T11:57:10-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 EWA (-distort resize) LanczosRadius3

Post by NicolasRobidoux »

Image
Image
Image
Image
Image
Image
Image
Image

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: sigmoidized EWA (-distort resize) LanczosRadius3

Post by NicolasRobidoux »

No wonder I like it: LanczosRadius3, with a little help from sigmoidization, is a good sharp but low jaggy scheme. The wizard and the dragon, for example, look quite good.

I am now convinced that 3-lobe Jinc with Radius 3 is a good candidate for tweaking the window function away from Jinc. Something that resembles Welch. When I have some time (I need to earn money "soon"), I'll actually see if I can use the Keys splines, tweaking the parameters to align the first crossing when the data is a 1D cardinal function.

I'm pretty sure that LanczosRadius3 should replace Robidoux as default EWA scheme, at least until I find something even better.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: sigmoidized EWA (-distort resize) LanczosRadius3

Post by NicolasRobidoux »

It looks like Welch is too aliased/halo-y with EWA Jinc Radius 3.
Jinc and Sinc windowing give basically the same result (with sigmoidization).
Cosine is in between.
Last edited by NicolasRobidoux on 2012-09-13T05:19:01-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 EWA (-distort resize) LanczosRadius3

Post by NicolasRobidoux »

I think EWA Jinc-windowed Jinc 3-lobe with Radius 3 wins over EWA Sinc-windowed Jinc 3-lobe with Radius 3. By a very very short nose.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: sigmoidized EWA (-distort resize) LanczosRadius3

Post by NicolasRobidoux »

There is no question to me that EWA LanczosRadius3 should replace Robidoux as the default EWA filter.
And, after a night of furious coding and testing, I don't think I can come up with a "sharp" EWA scheme which is better all around.
I've tried aligning the first (and second) crossings with 1D cardinal data with pixel lines, using a Blackman-Harris type window function (trying with one, two or three cosines), and I can't make it look good, whether I deblur the filter radius down to 3 or leave it as R3, the third root of Jinc. Maybe I did not quite try the right approach, or made coding or conceptual mistakes, but at this point, I'm really impressed with EWA Jinc-windowed Jinc 3-lobe with window radius set to exactly 3. Before, I was impressed. Now, I'm comparatively impressed :)

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: sigmoidized EWA (-distort resize) LanczosRadius3

Post by NicolasRobidoux »

Triple checking, and I cannot stress enough the high quality of EWA LanczosRadius3.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sigmoidized EWA (-distort resize) LanczosRadius3

Post by fmw42 »

NicolasRobidoux wrote:Triple checking, and I cannot stress enough the high quality of EWA LanczosRadius3.

What is your comparison analysis between the EWA and the equivalent or best tensor of the same methods, ie. -distort resize and resize

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: sigmoidized EWA (-distort resize) LanczosRadius3

Post by NicolasRobidoux »

@Fred:
According to the most important metric, the "Nicolas eyeball metric", it simply looks good, whether the image is text, pixel art or a DSLR photograph. It's quite sharp, and yet diagonal lines and interfaces are almost free of jaggies.
If it did not look good, I would not care for the numbers. However:
If re-enlarging images obtained by downsampling the high quality natural test images found in the http://www.imagemagick.org/download/ima ... ges/images with decent low pass filters (box, Gaussian, Lanczos 3, EWA Lanczos 3), EWA LanczosRadius3 is the fourth most accurate tested EWA method, after EWA Catmull-Rom (!!!), EWA LanczosSharpest4, and EWA LanczosSharpest3.
Now, EWA Catmull-Rom is basically the worst method (in terms of accuracy) when re-enlarging downsamples of the same images using nearest neighbour (with ties resolved by averaging so as to preserve alignment when using the align corners image geometry convention). It ranks just above ... nearest neighbour. EWA LanczosSharpest3 and 4 don't rank much higher. In addition, in images like the wizard or the dragon, they look horrible. Actually, if you look really carefully, they introduce, in natural images enlargements, artifacts that I find unacceptable. EWA LanczosRadius3 holds its ground among EWA methods, and actually ranks above tensor Lanczos 3 in this situation.
Maybe a slightly less strong deblur (something like .95, instead of about .92) would be better. But there is something clean about fitting the same number of EWA lobes into the tensor Lanczos 3 "box". And EWA LanczosSharp, with a deblur of about .98, kind of takes care of the "even less jaggies" end.
Also: EWA LanczosRadius3 gives results which are generally numerically close to tensor Lanczos 3 (or my favorite tensor method, Ginseng 3). So, if tensor Lanczos 3 is your ideal, EWA LanczosRadius3 is a pretty good EWA clone.
-----
I'll be more specific when Adam Turcotte's thesis is published.
But the bottom line for me is: It gives sharp results without obvious jaggyness.
Compare the results with Ginseng 3 (which are almost identical to those obtained with tensor Lanczos 3) with those obtained with EWA LanczosRadius3 and EWA LanczosSharp.
This is why I've redone (with slightly different sigmoidal values, but more or less comparable) the same tests with all three.
All 3 methods are good. They are my favorite (with the possible exception of LBB-Nohalo, which specializes in introducing zero halo whatsoever, which costs in jaggyness). However, given that decent looking EWA methods are invariably non-interpolatory, EWA LanczosRadius3 is a good compromise between the sharpness of tensor Lanczos 3 and the strong anti-aliasing of EWA LanczosSharp. I find tensor Ginseng 3 (and Lanczos 3) too jaggy: The checkerboard mode definitely is not damped enough for my taste.
-----
Sorry I can't give you a more convincing reason than, basically, "Look!".
Last edited by NicolasRobidoux on 2012-09-13T11:38:37-07:00, edited 3 times in total.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sigmoidized EWA (-distort resize) LanczosRadius3

Post by fmw42 »

Actually all I wanted to know was your (eyeball) comparison between EWA (-distort resize) LanczosRadius3 and tensor (-resize) LanczosRadius3

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: sigmoidized EWA (-distort resize) LanczosRadius3

Post by NicolasRobidoux »

Ah!
Here is:
Right now, I have 3 favorite all-purpose methods (leaving out LBB-Nohalo, which has a special purpose: no halo whatsoever).
Ginseng 3: tensor (-resize) Jinc-windowed Sinc 3 lobe. It's almost identical to regular tensor Lanczos (Sinc-windowed Sinc 3 lobe) but it's slightly less halo-y and jaggy without a noticeable increase in blurriness.
EWA Lanczos Radius 3: EWA (-distort resize) Jinc-windowed Jinc 3 lobe deblurred so that the radius of the EWA disk is exactly 3.
EWA LanczosSharp: EWA Jinc-windowed Jinc 3 lobe deblurred so that 1D cardinal data gives a Sinc-like function with a first crossing exactly where one wants it (at 1).

Summary:
Maximum sharpness, and interpolatory -> (tensor) Ginseng.
Willing to compromise on being interpolatory if jaggies are reduced a lot -> EWA Lanczos Radius 3.
No jaggies please (but definitely blurrier) -> EWA LanczosSharp.

And of course, if enlarging (or, at least, not downsampling much), I'd sigmoidize the lot, with a contrast value somewhere between 4 and 13.

@Fred: Clear?
Last edited by NicolasRobidoux on 2012-09-13T12:05:31-07:00, edited 4 times in total.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: sigmoidized EWA (-distort resize) LanczosRadius3

Post by NicolasRobidoux »

P.S. This being said, someone who likes -resize Mitchell should like -distort resize Robidoux, which can be described as an EWA clone.
Re-enlarging the said images downsampled with nearest neighbour, (tensor) Mitchell ranks first, then bilinear (!), Hann 2 and EWA Robidoux.
And EWA Robidoux, in IM, has one advantage over Mitchell and Hann 2: You don't need an IM compiled in HDRI to get top quality. (Not an issue with bilinear, but who cares.)
-----
Do >>I<< like these 2-lobe schemes better than my favorite 3-lobe schemes?
No, but I'm not "everybody".
And 2-lobe schemes have one less halo, which is something. And they're fast and cheap, and don't suffer as much from downsampling straight through sRGB.
(Yes, I know bilinear is a "1-lobe" method. Not a top choice, so does not matter.)
Last edited by NicolasRobidoux on 2012-09-17T07:22:04-07:00, edited 1 time in total.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sigmoidized EWA (-distort resize) LanczosRadius3

Post by fmw42 »

NicolasRobidoux wrote:Ah!
Here is:
Right now, I have 3 favorite all-purpose methods (leaving out LBB-Nohalo, which has a special purpose: no halo whatsoever).
Ginseng 3: tensor (-resize) Jinc-windowed Sinc 3 lobe. It's almost identical to regular tensor Lanczos (Sinc-windowed Sinc 3 lobe) but it's slightly less halo-y and jaggy without a noticeable increase in blurriness.
EWA Lanczos Radius 3: EWA (-distort resize) Jinc-windowed Jinc 3 lobe deblurred so that the radius of the EWA disk is exactly 3.
EWA LanczosSharp: EWA Jinc-windowed Jinc 3 lobe deblurred so that 1D cardinal data gives a Sinc-like function with a first crossing exactly where one wants it (at 1).

Summary:
Maximum sharpness, and interpolatory -> (tensor) Ginseng.
Willing to compromise on being interpolatory if jaggies are reduced a lot -> EWA Lanczos Radius 3.
No jaggies please (but definitely blurrier) -> EWA LanczosSharp.

And of course, if enlarging (or, at least, not downsampling much), I'd sigmoidize the lot, with a contrast value somewhere between 4 and 13.

@Fred: Clear?
Yes, that was what I was trying to understand. Thanks.

User avatar
anthony
Posts: 8884
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: sigmoidized EWA (-distort resize) LanczosRadius3

Post by anthony »

NicolasRobidoux wrote:Ah!
Here is:
Right now, I have 3 favourite all-purpose methods
If you like to write this up (text only or just SMALL examples), as a "Nicholas's Recommendations" I'll add it to the resize Examples page, to add at the very end.

I'll do the html formatting, unless you want to...

You can download the page to see how the formatting is done. Use a plain text editor. Please don't feed it to a HTML editor, they stuff up the HTML code I use for simple formatting for ALL browsers, and special codes used for execution of the command line examples.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Locked