PDA

View Full Version : non-ringing Lanczos scaling


madshi
1st March 2009, 14:41
Hey guys,

anyone interested in non-ringing Lanczos4 scaling? :D

Unfortunately I'm not an Avisynth developer, so I can only describe the algorithm, maybe someone else experienced with Avisynth can implement it.

(Caution: The following explanation is targeted at developers who know how Lanczos scaling works inside.)

---------------

First of all the contributors need to be sorted. The contributor which is nearest to the "center" (usually gets the highest weight) should be first in the list etc. The list should be sorted for distance to the center and not for weight. The sorted contributor list makes it easy to apply special processing to the "main contributors".

upscaling:
main contributors = first 2 contributors in the sorted list

downscaling:
main contributors = first "trunc(scale ratio) + 1" contribs

E.g. for 1.9x downscaling the main contributors are the first 2 contributors in the sorted list. For 2.0x downscaling the first 3.

Now calculate each destination value by using the usual Lanczos4 scaling, but additionally calculate the lowest and highest values of the main contributors. If the calculated destination value lies outside of the main contributors' value range, make sure that the destination value is modified to fit into range.

That is the main concept of the algorithm. Unfortunately it's not as easy as it sounds right now, because if you do this separately for X and Y scaling, there are sometimes some artifacts. Some of these can be avoided by keeping track (throughout the whole X + Y scaling process!) of the highest/lowest values of all main contributors which are used to calculate a destination value/pixel and to correct the destination pixels only after X + Y scaling is fully completed.

Here are some samples (scaled up 4x) with normal vs. anti-ringing Lanczos4 scaling:

http://madshi.net/lanczos/bad1.pnghttp://madshi.net/lanczos/good1.png

http://madshi.net/lanczos/bad2.pnghttp://madshi.net/lanczos/good2.png

http://madshi.net/lanczos/goodbw.pnghttp://madshi.net/lanczos/badbw.png

Unfortunately the algorithm isn't perfect. Look at the "out of order" text, it looks better without the anti-ringing extra processing. Maybe someone has an idea on how to further improve the algorithm? But I think it's working quite well already as it is...

Here is a bigger picture:

http://madshi.net/lanczos/lanczos.rar

neuron2
1st March 2009, 14:49
What's your source for this material?

How is this different from LimitedSharpenFaster?

Didée
1st March 2009, 15:12
It's the concept of LimitedSharpenFaster. The difference is that LSF first does its supersampling/resizing stuff with a standard lanczos or spline resizer, and the limiting comes after that. So, where the standard resizers do ring, there LSF will ring, too.

A basic resizer by the same method:

LanczosResize(dest_x,dest_y).Repair(Gaussresize(dest_x,dest_y,p=100),1)

madshi
1st March 2009, 15:50
What's your source for this material?
The original photos used for testing were downloaded somewhere from the internet.

A basic resizer by the same method:

LanczosResize(dest_x,dest_y).Repair(Gaussresize(dest_x,dest_y,p=100),1)
Hmmmmm... I didn't know the "Repair" filter. Seems that it uses the same concept, but it's not as well optimized for the specific case, I think. E.g. from what I've just read, "Repair" always compares 3x3 pixels. From my tests that's a good general purpose solution, but maybe not the best solution specifically for scaling. For upscaling I'm only comparing 2x2 pixels (those which are nearer to the "center"). For downscaling it can be more than 3x3 pixels, depending on the scale factor.

Or in short: The algorithm I described is custom tailored to "contributor" based resampling algorithms, by making use of the information in the contributor list. I think this should result in slightly superior quality because exactly those pixels are compared which are the main contributors to the final destination pixel. If we compare too many or not enough pixels, the algorithm should get a bit less effective (e.g. miss some ringing or misdetect ringing).

Maybe we should do some comparison tests?

One thing I'm wondering about: "LanczosResize.Repair" does appear to be rather similar to my suggestion. So why is it (seemingly) used rather rarely? At least from what I've read in the forums, many people complain about Lanczos ringing and I haven't ever seen "LanczosResize.Repair" being mentioned as a possible workaround.

neuron2
1st March 2009, 16:54
The original photos used for testing were downloaded somewhere from the internet. Can't you remember where? I want to read more about the algorithm.

Also, where do I find the Repair filter?

madshi
1st March 2009, 17:30
Can't you remember where?
The black&white image is from here:

http://compression.ru/video/resampling/index_en.html

The other two crops are from a photo I downloaded from a digicam review site, so not related in itself to scaling in any way. The original photo I used for testing is contained in the RAR linked in the first post.

I want to read more about the algorithm.
Do you mean the general Lanczos algorithm? In that case you can check out either AviSynth's source code or "swscale.c/h" (libav).

Or do you mean the algorithm I described here? I've "invented" that algorithm myself. So there's no website I can point you to. But if you know how Lanczos works then the description in the first post of this thread should be easy enough to understand. If you have any questions, just let me know...

But it seems that the basic concept of my algorithm was already used by "Repair" und "LimitedSharpenFaster" before. So I didn't really find anything new. Maybe a little quality optimization of what already existed.

Also, where do I find the Repair filter?
It's part of the AviSynth package "RemoveGrain". If you download "RemoveGrain", there's a HTML documentation inside which explains how "Repair" works.

Didée
1st March 2009, 17:51
The repair() method is pretty basic, yes. However, the main problem is one step deeper. The approach with clipping to not go beyond the limits of a given neighborhood has downsides. It prevents ringing/overshooting in those places where you don't want such. Yes. But it also prevents ringing/overshooting in those places where you do want it. Ouch#1. In both cases, the output signal is not smooth anymore, due to the possible clipping of the signal peaks. Ouch#2.
Rule of thumb: you don't want overshoot on one-step gradients, but you do want overshoot on the center of two-step gradients.

neuron2
1st March 2009, 19:33
Unfortunately I'm not an Avisynth developer, so I can only describe the algorithm, maybe someone else experienced with Avisynth can implement it.

How did you make screenshots of your algorithm if you could not implement it? You're really confusing me.

Fizick
1st March 2009, 20:43
neuron2,
he may be not Avisynth but for example Gimp developer...

madshi
1st March 2009, 22:21
The repair() method is pretty basic, yes. However, the main problem is one step deeper. The approach with clipping to not go beyond the limits of a given neighborhood has downsides. It prevents ringing/overshooting in those places where you don't want such. Yes. But it also prevents ringing/overshooting in those places where you do want it. Ouch#1. In both cases, the output signal is not smooth anymore, due to the possible clipping of the signal peaks. Ouch#2.
Yeah, I see the problems, they do show as artifacts.

Rule of thumb: you don't want overshoot on one-step gradients, but you do want overshoot on the center of two-step gradients.
That makes sense. The problem for me is that the pixel right next to an edge usually fails the "is this part of a gradient?" check - because the edge is right next to it. And this pixel is in danger of ringing. I've tried to detect gradients, but all I tried looked worse than the rather simple "clip any out of range values" approach.

How did you make screenshots of your algorithm if you could not implement it? You're really confusing me.
Sorry about the confusion. I've my own Delphi based scaling implementation. I came up with an IMHO ok looking workaround for the ringing problem so although I can't offer an AviSynth solution I thought I'd at least share the exact algorithm I'm using, in case one of the AviSynth devs is interested...

tetsuo55
15th April 2009, 09:20
This looks very interesting.

Although the nr-lancsoz has some artifacting i find this less disturbing than the ringing caused by normal lanczos.
I also find the words easier to read.

So we actually have 3 problems right?

*Ringing introduced by lanczos
*Artifacting introduced by Ringing fix
*Inability to handle gradients correctly.

Would it be possible/doable to use some kind of 2 pass approach?

1. Analyse image (filter out gradients)
2. Prepass NR-Lancsoz
3. Prepass "gradient-lanczos" ?
4. Merge result
5. Compare to original image to fix artifacting

Some expert could probably put all of this into 1 single pass...

madshi
15th April 2009, 10:46
*Ringing introduced by lanczos
*Artifacting introduced by Ringing fix
Yes.

*Inability to handle gradients correctly.
Huh?

tetsuo55
15th April 2009, 12:17
Huh?Your post earlier:That makes sense. The problem for me is that the pixel right next to an edge usually fails the "is this part of a gradient?" check - because the edge is right next to it. And this pixel is in danger of ringing. I've tried to detect gradients, but all I tried looked worse than the rather simple "clip any out of range values" approach.

madshi
15th April 2009, 12:34
Your post earlier:
This falls into the category "Artifacting introduced by Ringing fix". It's not a 3rd extra thing.

tetsuo55
15th April 2009, 13:02
This falls into the category "Artifacting introduced by Ringing fix". It's not a 3rd extra thing.

Ahh i guess i misunderstood that a separate problem

unix_sansei
17th April 2009, 15:45
add more lobes to reduce ringing or program up the mitchell or catrom.

madshi
17th April 2009, 19:22
add more lobes to reduce ringing
What!? Adding more lobes *increases* ringing.

or program up the mitchell or catrom.
That's not the point of this thread. Mitchell is noticeable softer than Lanczos. And Catmull-Rom has a lot more aliasing than Lanczos.

Gavino
17th April 2009, 20:27
Furthermore, Mitchell and Catmull-Rom are already available through BicubicResize.

unix_sansei
17th April 2009, 22:12
What!? Adding more lobes *increases* ringing.


That's not the point of this thread. Mitchell is noticeable softer than Lanczos. And Catmull-Rom has a lot more aliasing than Lanczos.


that's what i say What?

the infinite sync or besselj(arg)/arg are mathematically ideal for sampling.

when you window them, chop off lobes, you get ringing. the ringing is because your weights are relatively large negative if you have a very limited number of lobes. the more lobes you have the less significant the ringing as the negative coefficients are much smaller.

Mitchell are softer but generally they don't ring. so balance whether the softer is better overall or ringing.

madshi
18th April 2009, 12:38
the infinite sync or besselj(arg)/arg are mathematically ideal for sampling.

when you window them, chop off lobes, you get ringing. the ringing is because your weights are relatively large negative if you have a very limited number of lobes. the more lobes you have the less significant the ringing as the negative coefficients are much smaller.
That goes contrary to anything I've read and seen. See here:

http://audio.rightmark.org/lukin/graphics/lhouse_more.htm

You will notice that the "Sinc filter" has more ringing than anything else. The "Sinc filter" may be theoretically ideal, but it still has the most ringing compared to any other filter. If you think that this is not true, why don't you post a comparison screenshot between Lanczos and infinite Sinc filtering? I'd love to see infinite Sinc filtering without ringing!

Mitchell are softer but generally they don't ring. so balance whether the softer is better overall or ringing.
You seem to misunderstand the purpose of this thread. I didn't start this thread to get help in finding a filter which doesn't ring. The purpose of this thread is to discuss a specific algorithm I've found which allows to do Lanczos filtering without getting ringing. So talking about Mitchell is out of topic here...

Manao
20th April 2009, 09:41
Sinc filter won't ring if the input signal isn't aliased (but, alas, non-aliased input signal will already look too soft...)

madshi
20th April 2009, 18:58
Sinc filter won't ring if the input signal isn't aliased (but, alas, non-aliased input signal will already look too soft...)
Are you sure about that? It is my understanding that ringing is produced by "contributors" that are more than 1 pixel away from the center and which fall on contrasty edges. I don't see what aliasing has to do with it.

In the screenshot here:

http://audio.rightmark.org/lukin/graphics/lhouse_more.htm

... you can see that the Sinc filter shows very strong ringing for both aliased and non-aliased edges.

Manao
20th April 2009, 19:02
http://en.wikipedia.org/wiki/Whittaker%E2%80%93Shannon_interpolation_formula

Basically, if the signal isn't aliased, the limiting conditions are met, thus the sampling theorem states you can reconstruct the signal exactly.

madshi
20th April 2009, 19:20
http://en.wikipedia.org/wiki/Whittaker%E2%80%93Shannon_interpolation_formula

Basically, if the signal isn't aliased, the limiting conditions are met, thus the sampling theorem states you can reconstruct the signal exactly.
I read that wikipedia article differently. It lists two limiting conditions which must apply so that we can reconstruct exactly. These conditions are some funny math stuff. E.g. "The sampling rate, fs, must exceed twice the bandwidth". I don't even understand what this means for image resampling. Anyway, the wikipedia article does not list "non-aliased input" as one of the limiting conditions (which you stated in your previous post). Instead wikipedia says that the *output* of the Sinc filter will be aliased if those two limiting conditions are not met.

Anyway, do we agree that the Sinc filter rings more than Lanczos does?

Manao
20th April 2009, 19:34
Then check out aliasing's definition : http://en.wikipedia.org/wiki/Aliasing

*.mp4 guy
20th April 2009, 23:27
Manao is correct, also, perfectly band limited signals "never happen". If you created a reasonable imitation of a perfectly band limited signal using the imperfect tools available, it would look quite bad, and you would have a lower S/N/Resolution ratio then if you used more standard resampling methods.

madshi
21st April 2009, 08:39
I have to admit that I'm far from a math guy. So most of the discussion in the wikipedia articles is over my head. But anyway, I'm not really interested in things like "under specific theoretical circumstances the Sinc filter doesn't ring", if these circumstances usually do not apply to real world image/video content.

So can I get a straight answer out of you math gurus, please? :) Does the Sinc filter ring with typical real world image/video content? Does it ring more or less compared to e.g. Lanczos4?

Thanks!

Manao
21st April 2009, 08:51
On aliased images, it will ring more, because it isn't windowed.

madshi
21st April 2009, 12:02
Thanks.

NicolasRobidoux
4th June 2011, 00:28
...
... or besselj(arg)/arg are mathematically ideal for sampling.
...

Do you have references for this statement? (Besides Andreas Gustafsson's 1993 Helsinki UT Masters thesis and the fact that it's implemented in ImageMagick?)

NicolasRobidoux
4th June 2011, 00:30
I tried something related in this thread on the ImageMagick Forums (http://imagemagick.org/discourse-server/viewtopic.php?f=22&t=18458). (I was unaware that there were precedents.)

NicolasRobidoux
4th June 2011, 00:45
...
You seem to misunderstand the purpose of this thread. I didn't start this thread to get help in finding a filter which doesn't ring. The purpose of this thread is to discuss a specific algorithm I've found which allows to do Lanczos filtering without getting ringing. So talking about Mitchell is out of topic here...

(Possibly out of topic) LBB-Nohalo (LBB stands for "Locally Bounded Bicubic"; Nohalo stands for, well, "no halo", that is, no ringing), which is implemented in the
VIPS library: https://github.com/jcupitt/libvips/blob/master/libvips/resample/nohalo.cpp (https://github.com/jcupitt/libvips/blob/master/libvips/resample/nohalo.cpp), which is accessible via the NIP2 (http://www.vips.ecs.soton.ac.uk/index.php?title=Nip2) image resize tool (which, currently, does not align images "correctly" but otherwise works fine), and which is also found in the "samplers" git branch of the GEGL library (in a version, called lohalo, which does not use memory efficiently yet), is a method suitable for resampling and upsampling (but not downsampling) which introduces no ringing and which is pretty sharp and smooth (although it is more suited for non-noisy natural images than, say, binary images or noisy images).

NicolasRobidoux
4th June 2011, 02:02
I have to admit that I'm far from a math guy. So most of the discussion in the wikipedia articles is over my head. But anyway, I'm not really interested in things like "under specific theoretical circumstances the Sinc filter doesn't ring", if these circumstances usually do not apply to real world image/video content.

So can I get a straight answer out of you math gurus, please? :) Does the Sinc filter ring with typical real world image/video content? Does it ring more or less compared to e.g. Lanczos4?

Thanks!

Don Munsil (heard of him?) is of the opinion that frequency response is irrelevant w.r.t. image resizing. For example, search for "Don Munsil" in the ImageMagick Forums. (http://imagemagick.org/discourse-server/search.php?keywords=Don+Munsil&terms=all&author=&sc=1&sf=all&sr=posts&sk=t&sd=d&st=0&ch=300&t=0&submit=Search)

Needless to say, not everybody agrees.

My personal opinion is that frequency response matters, but that other things matter as well. What matters depends on what you're doing, and what kind of image you have.

P.S. I forgot to make the link to your query explicit: Basing a filter on the Sinc can only (pretty much) be justified with frequency response considerations.

*.mp4 guy
4th June 2011, 02:18
Frequency response matters, but so does impulse response. You get screwed if you blindly optimize for either one. People tend to get around this by using different filters on different types of content; the inevitable arguments over what the best filter is become more clearly pointless when you understand that none of them really work without a human deciding which is appropriate to the situation.

unix_sansei
4th June 2011, 05:28
Do you have references for this statement? (Besides Andreas Gustafsson's 1993 Helsinki UT Masters thesis and the fact that it's implemented in ImageMagick?)

you must be kidding this thread over 2 years old...

my own master's thesis dealt with computational electromagnetic fields and optics of lenses. the bessel function arguments are suited because of linear or differential recursion when integrated with a green's function or whatever your basis function is, they are numerically stable where other routines will break down, say on the shadow boundary of a lens. especially when you get in lomel and hankel functions of fractional order or spherical harmonics.

i wrote freakingly fast code in fortran in 32bits on solaris/sparc/dec alpha, back in 1992 that could compute coefficients faster than fft's and were orders of magnitude more accurate. in my case, i blew up and destroyed more professional fft libraries than anyone.

madshi
4th June 2011, 08:02
I tried something related in this thread on the ImageMagick Forums (http://imagemagick.org/discourse-server/viewtopic.php?f=22&t=18458). (I was unaware that there were precedents.)
Haha, I was 2 years faster... :)

But really, the credit belongs to Didée, he had a similar idea years before me for his LimitedSharpenFaster Avisynth script.

Don Munsil (heard of him?) is of the opinion that frequency response is irrelevant w.r.t. image resizing. For example, search for "Don Munsil" in the ImageMagick Forums. (http://imagemagick.org/discourse-server/search.php?keywords=Don+Munsil&terms=all&author=&sc=1&sf=all&sr=posts&sk=t&sd=d&st=0&ch=300&t=0&submit=Search)

Needless to say, not everybody agrees.

My personal opinion is that frequency response matters, but that other things matter as well. What matters depends on what you're doing, and what kind of image you have.
I've had some discussions with Don on AVSForum. He believes that more than 2 taps make no sense. But then based on his own arguments I asked him why using 2 taps at all, and why using negative lobes (he prefers Catmull-Rom), with his argumentation he should be using 1 tap. After that question he stopped responding... :p

BTW, what is your opinion about scaling in linear light? Don Munsil and Stacey Spears think it's all good. But recently I heard someone else say that it's good mainly for downscaling but not for upscaling.

NicolasRobidoux
4th June 2011, 12:16
...
BTW, what is your opinion about scaling in linear light? Don Munsil and Stacey Spears think it's all good. But recently I heard someone else say that it's good mainly for downscaling but not for upscaling.

Quick and dirty answer: If I had to make a bet, I'd put my money on linear light. But I don't like to gamble.

Less quick: It is reasonable, from a physical viewpoint, to see it as "obvious" that one should resample in linear light. However, when you are dealing with human perception, I'm not totally sure that "reasonable" always applies. This being said, people who compare the results of resampling in linear light (with careful convertion in and out of, say, sRGB) to "straight" appear to generally prefer the "through linear light" results. But I'm not sure the difference jumps at you.

Bottom line: I wish I had more experience/research results/forum threads/... to throw at you, but I don't. And this is not something I've given much thought to: I've always assumed that linear light is better, but I've also believed that it is not, generally, a huge deal. This being said, Oyvind Kolas, whose opinion I generally respect, set up the GEGL library (future GIMP engine) so it does everything in linear light. Anybody wants to place a wager?

(Now, maybe I should read the Doom9 and ImageMagick threads touching the topic... What you're getting is my "top of the hat" opinion, for what it's worth.)

Plausible is not the same as true.

NicolasRobidoux
4th June 2011, 12:32
By the way, when I read Don Munsil's statements RE: the irrelevance of frequency response, I went "Yes!"

This being said, the best all purpose filter I put together is the Clamped EWA Jinc Lanczos 3-lobes (in "straight" or "sharpened" versions) which one gets with "convert -filter lanczos (or lanczossharp) -distort resize" in ImageMagick (recent ImageMagick).

The construction of the non-sharpened version of this filter is motivated by a frequency response argument.

Just to say that reality has a way of disagreeing with opinions.

NicolasRobidoux
5th June 2011, 17:23
...
Maybe someone has an idea on how to further improve the algorithm? But I think it's working quite well already as it is...

It is working quite well indeed.

Suggestion #1: Don't try to eliminate all haloing. Try to have the "limiter" have a "soffter knee:" Let some haloing through, and consider yourself lucky that you can make the worst of it mostly disappear. Figure out how to set the "limiter" so as to leave things mostly alone when the haloing is "mild", and so that some of it is left when the haloing is "bad."

That is: Don't go for "perfect." Go for "better."

Suggestion #2: Use a scheme that has less haloing and jagginess from the get go like... Clamped EWA Jinc Lanczos 3-lobes.

NicolasRobidoux
5th June 2011, 20:13
For sake of comparison, here are the results obtained with five methods developed by my collaborators and me, on the "bull's eye" test image used by madshi in the original post of this thread: http://web.cs.laurentian.ca/nrobidoux/misc/halodemo/bullseye/

Three halo-free methods implemented in NIP2, and two EWA methods implemented in ImageMagick.

imagemagickewalanczossharp.png uses "sharpened" Clamped EWA Jinc Lanczos 3, a linear method which I highly recommend (note how it has basically no visible halo even though it is a linear method with negative lobes);

imagemagickewarobidoux.png uses Clamped EWA Robidoux bicubic, a linear method (the default ImageMagick EWA method);

nip2lbb.png uses LBB (Locally Bounded Bicubic), a nonlinear method;

nip2lbbnohalo.png uses LBB-Nohalo, a nonlinear method which I highly recommend ("Nohalo" image subdivision with LBB finish);

nip2vsqbs.png uses VSQBS (Vertex Split with Quadratic B-Spline finish), an extremely cheap linear method;

original.png is the original used to produce the enlargements.

madshi
5th June 2011, 20:48
Interesting. Looking at these results alone, I like "sharpened EWA Jinc Lanczos 3" and maybe "LBB". "LBB-Nohalo" looks pretty soft to me. But then, this is such an artifical test image. Without at least one good quality photo for comparison I can't really judge these algorithms properly.

FWIW, here are a couple comparisons:

standard Lanczos4: http://madshi.net/bwLanczos4.png
non-ringing Lanczos4: http://madshi.net/bwNonRingingLanczos4.png
modified ICBI: http://madshi.net/bwICBI.png
Progressive Refinement: http://madshi.net/bwPR.png
NNEDI3: http://madshi.net/bwNNEDI3.png
Imagiris: http://madshi.net/bwImagiris.png

Now let's do at least one good quality photo. If possible three or four.

NicolasRobidoux
5th June 2011, 20:59
...
Interesting. Looking at these results alone, I like "sharpened EWA Jinc Lanczos 3" and maybe "LBB". "LBB-Nohalo" looks pretty soft to me.
...

Warning: LBB-Nohalo is really meant for natural images. When used with a binary image, the slope limiting is so strong that there is no "sharpening", and LBB-Nohalo boils down to doubling the density with bilinear and then interpolating the double density result with LBB. The softness comes from the bilinear step.

Expect some more results (using your "parkmeter") soon.

madshi
5th June 2011, 21:26
Ok, here are the parkmeter results:

standard Lanczos4: http://madshi.net/parkingLanczos4.png
non-ringing Lanczos4: http://madshi.net/parkingNonRingingLanczos4.png
modified ICBI: http://madshi.net/parkingICBI.png
Progressive Refinement: http://madshi.net/parkingPR.png
NNEDI3: http://madshi.net/parkingNNEDI3.png
Imagiris: http://madshi.net/parkingImagiris.png

*.mp4 guy
5th June 2011, 22:07
For natural images, this comparison (http://www.general-cathexis.com/interpolation/index.html) is obligatory.

madshi
5th June 2011, 22:13
Yes, that's a good one, I've had that in my bookmarks for a long time. I also like to use the clown image for testing.

NicolasRobidoux
6th June 2011, 00:02
Ok, here are the parkmeter results:
...
standard Lanczos4: http://madshi.net/parkingLanczos4.png
non-ringing Lanczos4: http://madshi.net/parkingNonRingingLanczos4.png
modified ICBI: http://madshi.net/parkingICBI.png
Progressive Refinement: http://madshi.net/parkingPR.png
Imagiris: http://madshi.net/parkingImagiris.png
Here are mine:
http://web.cs.laurentian.ca/nrobidoux/misc/halodemo/parking

NicolasRobidoux
6th June 2011, 00:07
For natural images, this comparison (http://www.general-cathexis.com/interpolation/index.html) is obligatory.
I'm happy to do the "clown" and/or the "lighthouse," but I'd like to point out that the "original" images on the site are produced by downsampling with (orthogonal) Lanczos 3, and consequently they have a fairly unusual combination of quality features and artifacts.

In particular, the "small original images" have noticeable haloing to start with. The lighthouse has obvious moire to boot.

*.mp4 guy
6th June 2011, 01:43
I'm happy to do the "clown" and/or the "lighthouse," but I'd like to point out that the "original" images on the site are produced by downsampling with (orthogonal) Lanczos 3, and consequently they have a fairly unusual combination of quality features and artifacts.

In particular, the "small original images" have noticeable haloing to start with. The lighthouse has obvious moire to boot.
If you don't want to work with those images that's fine, but the clown image is of above average quality, and contains no glaring defects. It is generally what should be expected of competent linear interpolation.

The parking meter image also contains defects, it appears to have been box downsampled, which provides insufficient protection from aliasing, which is manifest quite clearly in the results of interpolating it. I bring this up only to indicate that most source images that are available will contain defects.

The moire in the lighthouse image is not severe and is almost completely removed by even basic linear interpolation. It represents a tractable and non-pathological test for ability to avoid/correct minor more when interpolating.

NicolasRobidoux
6th June 2011, 02:29
Here are the clown enlargements: http://web.cs.laurentian.ca/nrobidoux/misc/halodemo/clown/

NicolasRobidoux
6th June 2011, 02:53
Here are the lighthouse enlargements: http://web.cs.laurentian.ca/nrobidoux/misc/halodemo/lighthouse/

NicolasRobidoux
6th June 2011, 03:04
Quick note: LBB has two versions; I used the less smooth one. LBB-Nohalo has two versions; I used the smoother one. In my limited testing, each is the best of the two alternatives.

madshi
6th June 2011, 08:24
clown:

standard Lanczos4: http://madshi.net/clownLanczos4.png
non-ringing Lanczos4: http://madshi.net/clownNonRingingLanczos4.png
modified ICBI: http://madshi.net/clownICBI.png
Progressive Refinement: http://madshi.net/clownPR.png
NNEDI3: http://madshi.net/clownNNEDI3.png
Imagiris: http://madshi.net/clownImagiris.png

lighthouse:

standard Lanczos4: http://madshi.net/lighthouseLanczos4.png
non-ringing Lanczos4: http://madshi.net/lighthouseNonRingingLanczos4.png
modified ICBI: http://madshi.net/lighthouseICBI.png
Progressive Refinement: http://madshi.net/lighthousePR.png
NNEDI3: http://madshi.net/lighthouseNNEDI3.png
Imagiris: http://madshi.net/lighthouseImagiris.png

@Nicolas, can you do the lighthouse in 400% instead of 200%, please?

NicolasRobidoux
6th June 2011, 19:04
...
@Nicolas, can you do the lighthouse in 400% instead of 200%, please?

Done. I put them at the same place (removed the 200% ones).

Note: LBBNohalo, for example, preserves more of the moire present in the house siding.

Does it make sense to you (or *.mp4_guy) that we actually do a 400% of the original lighthouse image (pre-downsampling with Lanczos 3)? It's available on the http://www.general-cathexis.com/interpolation/index.html site.

We could call them "biglighthouse" or something like that?

NicolasRobidoux
6th June 2011, 19:18
The results make me wonder:

1) How well Non-ringing Clamped EWA Jinc Lanczos 3 would turn out.

2) Whether Clamped EWA Jinc Lanczos 3 (or a non-ringing version) should replace LBB as finishing scheme for Nohalo subdivision.

madshi
6th June 2011, 19:18
@Nicolas, if you think it's worthwhile we can do that (biglighthouse, I mean).

@Anybody, is anybody able to provide 400% NNEDI3 screenshots of those 4 images (black&white, parking, clown, lighthouse)? I'm an AviSynth noob, unfortunately. The originals can be found in Nicolas' download links.

LoRd_MuldeR
6th June 2011, 19:38
@Anybody, is anybody able to provide 400% NNEDI3 screenshots of those 4 images (black&white, parking, clown, lighthouse)? I'm an AviSynth noob, unfortunately. The originals can be found in Nicolas' download links.

This should do the trick:

ImageSource("C:\Foo\Bar.png")
NNEDI3_rpow2(rfactor=4)

NicolasRobidoux
6th June 2011, 19:50
I've looked at the image which http://www.general-cathexis.com/interpolation/index.html states the "small" lighthouse was obtained from, namely http://www.general-cathexis.com/interpolation/BigLight.png, and it's pretty clear to me that this image too saw some significant processing. Too much haloing and aliasing, for example, to be a reasonably unprocessed image. It actually looks to me like it was obtained by downsampling with Lanczos 2 from an even larger original (or else, by some sort of smoothing followed by USM).

I still think it's a good test image, so I'll proceed to enlarge "biglighthouse" 4x anyway. But I wanted this fine print out in the open.

NicolasRobidoux
6th June 2011, 20:06
Here are the "biglighthouse" enlargements: http://web.cs.laurentian.ca/nrobidoux/misc/halodemo/biglighthouse/

madshi
6th June 2011, 20:12
Here's another good candidate for testing:

http://img69.imageshack.us/img69/6127/z3hs1n8ns1t.png

madshi
6th June 2011, 20:33
This should do the trick:

ImageSource("C:\Foo\Bar.png")
NNEDI3_rpow2(rfactor=4)
Thanks, that works.

NicolasRobidoux
6th June 2011, 21:26
Here are the "castle" enlargements: http://web.cs.laurentian.ca/nrobidoux/misc/halodemo/castle/.

(Note: The "castle" is another test image with haloing in the original.)

madshi
6th June 2011, 21:33
I've added NNEDI3 screenshots to all the previous comparison of the last 1-2 days. And here are the castle and biglighthouse comparisons:

castle:

standard Lanczos4: http://madshi.net/castleLanczos4.png
non-ringing Lanczos4: http://madshi.net/castleNonRingingLanczos4.png
modified ICBI: http://madshi.net/castleICBI.png
Progressive Refinement: http://madshi.net/castlePR.png
NNEDI3: http://madshi.net/castleNNEDI3.png
Imagiris: http://madshi.net/castleImagiris.png

big lighthouse:

standard Lanczos4: http://madshi.net/biglighthouseLanczos4.png
non-ringing Lanczos4: http://madshi.net/biglighthouseNonRingingLanczos4.png
modified ICBI: http://madshi.net/biglighthouseICBI.png
Progressive Refinement: http://madshi.net/biglighthousePR.png
NNEDI3: http://madshi.net/biglighthouseNNEDI3.png
Imagiris: http://madshi.net/biglighthouseImagiris.png

NicolasRobidoux
6th June 2011, 21:38
Without a doubt, the "Robidoux" EWA filter is out of the running.
VSQBS is nice but too blurry, I would guess, for most people (although it may work well with "pixel art," noisy, or jpeg compressed images, and it's even cheaper than a bicubic scheme: it's a "clean" linear scheme with an 8 point stencil in 2D).
And I consistently find that LBB has more "jaggies" than LBB-Nohalo.

On my "side", this leaves (no surprise here) LBB-Nohalo and Clamped EWA Jinc Lanczos 3, the two schemes I presented at Libre Graphics Meeting 2011 (http://river-valley.tv/better-and-faster-image-resizing-and-resampling/).

NicolasRobidoux
6th June 2011, 21:45
Unless someone suggests more test pictures, I think call-in's open.

madshi
6th June 2011, 22:36
So here are my quality judgements. I'm leaving nip2vsqbs and standard Lanczos4 out of these judgements because nip2vsqbs is way too soft and Lanczos4 has way too many ringing artifacts.

black&white: NNEDI3 > ICBI > PR > EWA LanczosSharp > nonRingingLanczos4 > EWA Robidoux > LBB > LBB-Nohalo > Imagiris
parking: NNEDI3 > Imagiris = ICBI > nonRingingLanczos4 > PR > LBB-Nohalo > LBB > EWA LanczosSharp > EWA Robidoux
clown: NNEDI3 > Imagiris > ICBI > EWA LanczosSharp > nonRingingLanczos4 > PR > LBB-Nohalo > LBB > EWA Robidoux
lighthouse: NNEDI3 > ICBI > Imagiris > EWA LanczosSharp > nonRingingLanczos4 > EWA Robidoux > PR > LBB-Nohalo = LBB
castle: NNEDI3 > Imagiris > nonRingingLanczos4 > EWA LanczosSharp > PR > LBB = LBB-Nohalo > EWA Robidoux > ICBI
biglighthouse: NNEDI3 > Imagiris > ICBI > PR > EWA LanczosSharp > nonRingingLanczos4 > LBB-Nohalo > EWA Robidoux > LBB
Here comes my opinion about those scaling algorithms one by one, sorted for quality:

(1) NNEDI3: clear winner for me. Not as sharp as Imagiris, but always artifact free, always aliasing free, always halo free, always smooth and pretty, big congrats to tritical
(2) Imagiris: best in sharpness, but too many artifacts to win, probably not a good choice for video, due to artifacts
(3) ICBI: somewhat comparable to NNEDI3 in looks, but a clear step down, also shows some minor artifacting sometimes
(4) EWA LanczosSharp + nonRingingLanczos4: EWA LanczosSharp has noticeably lower aliasing levels than nonRingingLanczos4, but has more halos and is a bit softer
(5) PR: weird algorithm, produces sometimes quite nice results, sometimes rather bad results, sometimes weird artifacts, no good choice for video, due to artifacts
(6) LBB-Nohalo: Too much aliasing for my taste. But on the positive side no halos (surprise!)
(7) LBB: In many cases almost identical to LBB-Nohalo. Sometimes a tiny bit worse.
(8) EWA Robidoux: Too much aliasing and softer than LBB(-Nohalo).

Of course that's just my personal opinion. Anyone else willing to do a detailed judgement?

Malcolm
30th August 2011, 22:40
(1) NNEDI3: clear winner for me. Not as sharp as Imagiris, but always artifact free, always aliasing free, always halo free, always smooth and pretty, big congrats to triticalimho: NNEDI3 has some artifacts in this region: http://img718.imageshack.us/img718/1903/lighthousennedi3crop.th.jpg (http://imageshack.us/photo/my-images/718/lighthousennedi3crop.jpg/)

madshi
31st August 2011, 08:45
imho: NNEDI3 has some artifacts in this region
Ok, have to agree with that. But then, these artifacts don't fall into the "nasty" category, IMHO. I consider the aliasing visible in most other screenshots worse.

Anyway, what is your preference? Which algorithm like you best overall?

nevcairiel
31st August 2011, 13:18
Imagiris looks like some kind of oil-painting filter from Photoshop, horrible imho. Alot of detail looks just washed out. Quite obvious on the castle image, not as pronounced on big lighthouse.
How did you make it #2?

I agree with your #1, NNEDI3 seems to be the best in all of the sample images.

madshi
31st August 2011, 14:05
Imagiris looks like some kind of oil-painting filter from Photoshop, horrible imho. Alot of detail looks just washed out. Quite obvious on the castle image, not as pronounced on big lighthouse.
How did you make it #2?
Well, I do like the Imagiris sharpness, and aliasing is nicely low, too. Yes, sometimes it looks a bit like oil painting, that's true. But which algorithm would you select as #2? ICBI? It's not bad, but it does sometimes still show artifacts, too, and is much softer than Imagiris. Of course 400% is also rather big. The Imagiris oil painting look is less pronounced at lower scaling factors. But anyway, for my taste NNEDI3 is far ahead of everything else. I'd really like to know how the following algorithm compares, though:

http://www.resampling.narod.ru/

tritical
31st August 2011, 16:27
No enlargement method will be completely free of artifacts (including NNEDI3) simply because the missing information makes it ambiguous in some cases as to what the pixel value in the enlarged image should be. I do think NNEDI3 hides its artifacts well though... mainly because the output it predicts tends to look like image structure it saw during training, and its output does not change substantially for small changes of the input (which is a major problem with a lot of heuristic edge directed methods).

However, IMO using NNEDI3 for enlarging will give you an image that really should be sharpened.

The downsizing process for a gamma corrected image (in a good software implementation - and pretty close to what you get with a camera) is basically:

1.) undo gamma correction
2.) low pass filter (gaussian blur)
3.) apply gamma correction
4.) sample or interpolate

3 and 4 can be switched without significant change (none if simply sampling). So the inverse steps would be:

1.) enlarge with NNEDI3
2.) undo gamma correction
3.) attempt to inverse gaussian blur (sharpen)
4.) apply gamma correction

A while ago I actually trained some mixture of experts models to inverse different amounts of gaussian blur (both on linear light and gamma corrected) in an attempt to improve NNEDI3 enlargements. It worked quite well. I can't remember why I never released it. The only downside was that the user would have to select between the different models (trained to inverse different amounts of gaussian blur) and choose what looked best. There was no attempt to automatically choose which inverse to apply.

madshi
31st August 2011, 17:04
its output does not change substantially for small changes of the input
That's quite important.

However, IMO using NNEDI3 for enlarging will give you an image that really should be sharpened.
Agreed.

The downsizing process for a gamma corrected image (in a good software implementation - and pretty close to what you get with a camera) is basically:

1.) undo gamma correction
2.) low pass filter (gaussian blur)
3.) apply gamma correction
4.) sample or interpolate

3 and 4 can be switched without significant change (none if simply sampling). So the inverse steps would be:

1.) enlarge with NNEDI3
2.) undo gamma correction
3.) attempt to inverse gaussian blur (sharpen)
4.) apply gamma correction

A while ago I actually trained some mixture of experts models to inverse different amounts of gaussian blur (both on linear light and gamma corrected) in an attempt to improve NNEDI3 enlargements. It worked quite well. I can't remember why I never released it. The only downside was that the user would have to select between the different models (trained to inverse different amounts of gaussian blur) and choose what looked best. There was no attempt to automatically choose which inverse to apply.
Sounds interesting. What happens if you use wrong blur parameters?

I've had two thoughts about how NNEDI3 could eventually be improved:

(1) NNEDI3 is trained to find "missing" lines (mainly for deinterlacing), correct? And when "enlarging" the image, you don't modify the original pixels, you just find new pixels for the "missing" lines, correct? But in a downsampled image every pixel is already some kind of filtered. So wouldn't it be better to rewrite *all* output pixels, instead of just filling the missing pixels? Shouldn't that allow you to produce sharper results?

(2) Have you thought about trying some different criteria during NNEDI3 training? E.g. it seems that your new version using the absolute error works better than the squared error. Here my thinking is that the human eye is most sensitive to edges, but neither absolute nor square error take that into account. Wouldn't it make sense to find an error measurement which puts more priority on edge quality than on just the average error? Maybe you could try using things like "PSN&ER", as described here:

The base of the suggested algorithm (M-spline) lies in application of the new PSN&ER metrics (peak to peak signal to noise and edges ratio) which significantly more accurate (compared with PMS metrics) agrees with the visual valuation of similarity.
Does that make any sense to you?

NicolasRobidoux
31st August 2011, 17:16
I believe that many people consider MAE (mean absolute error a.k.a. l1 or L1 error) to be a better measure than MSE/PSNR/RMS (a.k.a. l2 or L2) error in image processing.

madshi
31st August 2011, 17:23
Interesting, didn't know that.

tritical
31st August 2011, 18:24
(2) Have you thought about trying some different criteria during NNEDI3 training? E.g. it seems that your new version using the absolute error works better than the squared error. Here my thinking is that the human eye is most sensitive to edges, but neither absolute nor square error take that into account. Wouldn't it make sense to find an error measurement which puts more priority on edge quality than on just the average error? Maybe you could try using things like "PSN&ER", as described here:

I've thought about it before. In the past I've tried SSIM. The biggest problem is that for online training - the only way to be able to train on lots of data in a reasonable amount of time - I need a quickly differentiable error metric that is independent between patterns. That essentially limits me to Lp norms (absolute error, squared error, etc...). It would be possible to use a second metric for fine tuning after a good initial solution is found, and that optimization could be done in a batch manner without needing derivatives. However, I have not found a metric that improves significantly over L1. One thing to remember is that the prediction network is only trained on parts of the image that pass the pre-screener... so effectively it is concentrating on edge areas.

The "PSN&ER" reference also caught my attention when I read the page you linked to, but they don't explain anything about it - and a search with google turned up nothing. One metric that I have looked into is PSNR-HVS-M. So far I have not done this 'fine tuning' of the NNEDI3 models using a more complex metric. It is a good idea though.

tritical
31st August 2011, 18:33
(1) NNEDI3 is trained to find "missing" lines (mainly for deinterlacing), correct? And when "enlarging" the image, you don't modify the original pixels, you just find new pixels for the "missing" lines, correct? But in a downsampled image every pixel is already some kind of filtered. So wouldn't it be better to rewrite *all* output pixels, instead of just filling the missing pixels? Shouldn't that allow you to produce sharper results?

I don't think NNEDI3 should modify the original pixels. It is trained to recreate missing pixels at the same scale and sharpness as the input (and it is trained in gamma corrected values). It essentially corresponds to exactly what step 1 of the enlargement process should be IMO. I do, however, think the original pixels (and the predicted pixel values) should be modified when performing the blur inversion (sharpening).

Sounds interesting. What happens if you use wrong blur parameters?

Nothing really. You would just end up with a sharper or blurrier version of the image. It is basically user preference anyway. In a metric evaluation, choosing the incorrect one would result in objectively worse quality than choosing the right one. In my experience, current objective metrics are quite horrible for judging image enlargement (shrink an image (usually using a very poor method), enlarge, compare to original).

madshi
31st August 2011, 18:55
Ah, that's interesting!

Looking forward to what you'll be cooking up next! :)

NicolasRobidoux
31st August 2011, 18:58
I've thought about it before. In the past I've tried SSIM...

My student Adam Turcotte and I have devised an improved SSIM which is smoother with respect to variations in image size, alignment and boundary features and which runs much much faster. It otherwise gives pretty much the same answer.

We have unpublished code which relies on the VIPS library. It is lightning fast. (For one thing, we figured out how to eliminate two of six filtering steps.)

We may be interested in working with you to tweak it for training use.

You can access prelimary versions through my ohloh web site:
www.ohloh.net/accounts/NicolasRobidoux

(We're unfortunately behind in putting stuff on the web/packaging things so they are useable by others, but we could up the priority.)

NicolasRobidoux
31st August 2011, 19:18
Then again, if you are only using SSIM on small patches of fixed size <= 256x256 or so which are not the result of downsampling and are not too small, our improvements probably don't matter.

IanB
31st August 2011, 22:31
(2) Have you thought about trying some different criteria during NNEDI3 training? E.g. it seems that your new version using the absolute error works better than the squared error. Here my thinking is that the human eye is most sensitive to edges, but neither absolute nor square error take that into account. Wouldn't it make sense to find an error measurement which puts more priority on edge quality than on just the average error? ...
A cheapish implementation could be to scale the absolute error values by the 1st derivative of the image, e.g. E*(mx'+c), the current model is m=0 and c=1. I would start with conservative values like m=1/16th.

Thoughts?

NicolasRobidoux
31st August 2011, 22:39
Note: If I remember correctly, MAE already gives more weight to "boundary tracking" errors (near rapid changes) than RMSE.

NicolasRobidoux
31st August 2011, 22:44
Opinion: Already in the current NNEDI, the most noticeable errors come from creating sharp interfaces where there are none. Given that derivative computations are greatly affected by noise, my guess is that NNEDI will not be improved by using weights involving gradients, at least not on "unclean" natural images.

Rumbah
4th September 2011, 14:37
Would it be possible to release the training program and some interesting work units and let the community use their horse power to execute the training?
That way you can experiment with different settings without having to run the training itself as it seems very time consuming. I guess a lot of people would help and contribute to get a "better" nnedi.

redfordxx
4th November 2011, 18:35
I read only few posts here, not all, so I don't know if this contributes to something or it is already used or known or implemented.
Recently I was interested in resizing and/or sharpening and generally got annoyed by ringing...so I got idea

Here:
Ringing occures when second derivation changes the sign (convex changes into concave)
So if that could be limited, there will be no more ringing.
I also tried to make script which does it, bot go stuck on other thing: noise...:-(

NicolasRobidoux
29th November 2011, 02:14
As documented in http://forum.doom9.org/showthread.php?p=1541448#post1541448, I have produced sharper versions of the Robidoux, Jinc-windowed Jinc 3-lobe and 4-lobe EWA (Elliptical Weighted Averaging) filters for ImageMagick. I have posted the results under the names RobidouxSharp.png, JincJinc3blur0p88549061701764.png and JincJinc4blur0p88451002338585141.png alongside my earlier results in the folders found at http://web.cs.laurentian.ca/nrobidoux/misc/halodemo/ (web.cs.laurentian.ca/nrobidoux/misc/halodemo/).

madshi
29th November 2011, 09:04
Hmmmmm... The new images are definitely sharper, but I'm still not sure if I prefer them over your old LanczosSharp. The new images have noticeably more ringing and more aliasing in some of the test images. E.g. check out the roofs on the "biglighthouse" and "castle" images. Your old LanczosSharp method shows some ringing there, but at least it's relatively faint and not aliased. Both new methods show stronger and more aliased ringing there. The wood wall in the left house in "biglighthouse" also shows a lot more ringing (if it's ringing what I see there) compared to the old LanczosSharp image. In the "parking" image, one of your new LanczosSharp variations shows much stronger ringing at the left side of the parking case, the other one weaker ringing, compared to your original LanczosSharp implementation. Weird. Both new algorithms have more ringing and aliasing artifacts within most of the texts in the "parking" image. Your original LanczosSharp produced more natural and artifact free images, IMHO, but also softer.

Just my 2 cents, of course. And to be honest, I've no clue about the math behind your old and new algorithms. So I can only compare the image results with my eyes.

What do you think?

*.mp4 guy
29th November 2011, 11:28
Most of the test images are more aliased then would generally be expected. This results in a marked bias in favor of more aggressive filters, likely other images would show the opposite result.

NicolasRobidoux
29th November 2011, 13:02
Hmmmmm... The new images are definitely sharper, but I'm still not sure if I prefer them over your old LanczosSharp.

What do you think?

@madshi: Thank you very much for your feedback Mathias.

-----

In a ("mathematical") sense, the new Jinc-windowed Jinc filters are the sharpest Jinc-windowed Jinc EWAs possibles with the given number of lobes. No surprise, they are more aliased.

I agree that with this collection of test images, this is a Goldilocks situation: "classic" LanczosSharp appears to be a bit too soft, and the new ones too sharp.

It turns out that I had done my preliminary testing with a group of images which had little or no haloing as well as generally softer. With those, the new sharper versions were, to my eyes, right at the edge of "too sharp." With this group of test images, they appear to me to have crossed the line. I myself find them too aliased. And I don't like that the existing halos are sometimes noticeably amplified.

What this suggests to me is that the "best Jinc-windowed Jinc EWAs" have a support that sits between the "new" and the "old." In http://imagemagick.org/discourse-server/viewtopic.php?f=22&t=19636&start=30#p78406, I suggested rescaling the Jinc-windowed Jinc EWA filters so that the radius is exactly the number of lobes, which is basically what is the case for orthogonal Sinc-windowed Sinc Lanczos. I don't have a mathematical justification for this choice. But this produces a scheme which sharp Goldilocks may approve of without any of the halo-free bears complaining too loudly.

This particular group of test images made me realize that, for example, the 4-lobe version is not as good across the board as I thought.

madshi
29th November 2011, 14:06
@*.mp4 guy, you may be right, I'm not sure. Here on doom9 we're usually more concerned about video than still photo, and video is often softer than these still photos. But then there's a big difference between DVDs and good Blu-Rays. Some Blu-Rays are very detailed and would probably also result in aliasing and definitely in haloing with too sharp resampling filters.

@Nicolas, have you thought about adding some anti-ringing logic to your resamplers? E.g. if you compare your EWA Lanczos results (any of them) of the "castle" image to my "non-ringing Lanczos", mine has noticeably less ringing at the roof. Maybe if you used a similar technique in your algorithms you could improve quality further? Just a thought, though... Personally, I'm tending to go totally non-linear at the moment. I think we're at the limit of what "simple" linear resampling can do. If we want another significant jump in image quality, I think non-linear algorithms will be the way to go. Which is confirmed by the NNEDI3 results, which I still find noticeably superior to any other algorithm tested in this thread. As a start I'm planning to look into improving my non-ringing Lanczos algorithm, maybe by adjusting the resampling weights to match the edge directions or something like that. I'll probably use a more trial-and-error approach instead of science and math, though, because I'm not too great in the latter areas... ;)

NicolasRobidoux
29th November 2011, 14:53
...
@Nicolas, have you thought about adding some anti-ringing logic to your resamplers? E.g. if you compare your EWA Lanczos results (any of them) of the "castle" image to my "non-ringing Lanczos", mine has noticeably less ringing at the roof. Maybe if you used a similar technique in your algorithms you could improve quality further? Just a thought, though... Personally, I'm tending to go totally non-linear at the moment. I think we're at the limit of what "simple" linear resampling can do. If we want another significant jump in image quality, I think non-linear algorithms will be the way to go. Which is confirmed by the NNEDI3 results, which I still find noticeably superior to any other algorithm tested in this thread. As a start I'm planning to look into improving my non-ringing Lanczos algorithm, maybe by adjusting the resampling weights to match the edge directions or something like that. I'll probably use a more trial-and-error approach instead of science and math, though, because I'm not too great in the latter areas... ;)

@Mathias:

There is a lot here.

Initial answer:

It's only been about a year (I believe) that anyone got a truly good EWA scheme working. So, I'm still exploring linear EWA. One way of modifying weights is by changing the windowing function. In quick experiments documented on the ImageMagick forums, I found that Jinc is probably the best windowing function for Jinc. But I'm not sure. And it does lead to lots of haloing sometimes.

What seems to be tricky is to side step the zero sum. Weights/kernels can be modified to reduce haloing (say), but then some other annoying artifact sticks its head out.

My novel schemes LBB and LBB-Nohalo are nonlinear. LBB is specifically designed to prevent haloing. LBB really can be described as bicubic with very strong ringing suppression. LBB-Nohalo does that, and attempts to straighten/sharpen diagonal lines. But they don't work well with images which contain haloing to start with, and they are aliased with "old skool CG." A Masters student of mine (Chantal Racette) is defending this Friday, with a core component of the thesis a discussion of these two methods. (She actually was involved in the intial ImageMagick fixing of EWA, but this part of her work did not really make it in her thesis.)

I have, on the back of an envelope, a less "halo averse" bicubic method which should be an improvement on LBB. A more balanced scheme if you wish. It is nonlinear, although less so than LBB. I have high hopes for this one. It is based on a biquadratic method discussed in the thesis which works fairly well in 1D but is not very good in 2D.

NNEDI3 is simply amazing. Although I wonder how it does with video, because it's clear that it "invents" attractive pieces where other schemes would add artifacts, and it would not surprise me that this type of strong nonlinearity would make details "jump" from one frame to the next. I also, personally, do not particularly like its "glossiness". Naturally messy things like grass or conifer branches don't look natural to me. It's almost as if NNEDI3 creates a "plastic world" ("I'm a Barbie girl, in a Barbie world..."). It makes think of what comes out of using a Jensen filter.

I do wonder if a nonlinear face or vertex split subdivision method which explicitly takes into account what we "expect" to see at higher resolution with a collection of archetypal data patches could almost match NNEDI3. But I have no time for that now.

I can use math to guide me, but math is limited in the guidance it provides. My opinion is that designing a good image resampling method is a craft. I trust my eyes more than numbers alone. I do find that there are some mathematical properties that provide useful guidance or tuning values. But this whole thing still appears to me hugely complicated, and I don't have a clear vision of what is "the" way.

Good luck. Keep documenting what you try, please.

madshi
29th November 2011, 15:12
NNEDI3 is simply amazing. Although I wonder how it does with video, because it's clear that it "invents" attractive pieces where other schemes would add artifacts, and it would not surprise me that this type of strong nonlinearity would make details "jump" from one frame to the next.
NNEDI3 was originally invented for deinterlacing, so video is the primary purpose. And it seems to work quite well there. The problem you're anticipating can definitely happen with certain algorithms but it seems NNEDI3 is not one of them.

I also, personally, do not particularly like its "glossiness". Naturally messy things like grass or conifer branches don't look natural to me.
NNEDI3 decides for which parts of the image to use the NNEDI3 algorith and for which parts simple Bicubic. Usually grass and trees end up being upscaled with Bicubic. I've once tried forcing NNEDI3 on for all pixels and it didn't look well for grass and trees at all, IMHO. It looked more fractal like than natural there. The real purpose of the Bicubic switch was to save performance. Luckily it also seems to avoid many of those fractal artifacts. Other non-linear algorithms have similar problems. E.g. this one easily beats NNEDI3, from what I can see:

http://resampling.narod.ru/

But it doesn't look good for grass and trees, either. I think these kind of problems should be solvable, though. Grass and trees are usually image areas with a lot of random directions. It should be possible to detect such areas and use a different algorithm for them.

I believe this "unnatural" or "fractal" like look of grass/trees usually happens if you have an algorithm which tries to find edge directions in the image and interpolate them "correctly". Doing so often works *great* for most image content, just not for mother nature (grass, trees).

I can use math to guide me, but math is limited in the guidance it provides. My opinion is that designing a good image resampling method is a craft. I trust my eyes more than numbers alone. I do find that there are some mathematical properties that provide useful guidance or tuning values. But this whole thing still appears to me hugely complicated, and I don't have a clear vision of what is "the" way.
Yeah, I think logical thinking and good ideas might work better for image resampling than pure math. Oh well, probably a good combination of both would be ideal. Maybe I should polish my math up... :o

Keep documenting what you try, please.
Will do. You, too, please.