Page 16 of 19

Re: best downsampling method for DSLR photographs

Posted: 2012-09-21T04:53:15-07:00
by NicolasRobidoux
I am revising my recommendations.

Re: best downsampling method for DSLR photographs

Posted: 2012-09-22T09:25:35-07:00
by NicolasRobidoux
Here is something rather amusing:
On the fly image (the only one I've tested yet), the following two methods are close to being clones when downsampling to the usual 403x600 size:

Tensor filtering with the bilinear (Triangle) filter, just about the simplest and cheapest method possible:

Code: Select all

original.jpg -colorspace RGB -filter Triangle -resize 403x600 -colorspace sRGB fly.Triangle.png
And EWA (Elliptical Weighted Averaging) cubic B-spline windowed Jinc 2-lobe, which qualifies as a "fancy" method:

Code: Select all

convert original.jpg -colorspace RGB -define filter:window=Spline -define filter:lobes=2 -distort resize 403x600 -colorspace sRGB fly.EWASplineJinc2.png
Both are reasonably moire free, and not particularly sharp. Here, I show the -resize Triangle result:
Image
P.S. They are also near clones with the backpack. I bet you anything that the cardinal function for cubic B-spline windowed Jinc 2-lobe is basically the tensor product of the Mexican hat with itself. The EWA method is a minuscule amount sharper and has a minuscule amount more moire.
P.S. Anthony has been wanting a decent looking EWA method which is reasonably close to interpolatory (which he expresses in terms of what it does, under no-op, with the hash pattern). Could quadratic or cubic-spline windowed Jinc 2-lobe do the job? Orthogonal Triangle is interpolatory. Not very good looking, but interpolatory. If an EWA scheme is a near clone... (Of course EWA RobidouxSharp is also pretty close to interpolatory.)

Re: best downsampling method for DSLR photographs

Posted: 2012-09-22T12:24:46-07:00
by NicolasRobidoux
I don't know exactly where this is going, but here is a downsampler with no second halo (even though it formally uses 3 lobes): EWA cubic B-spline windowed Jinc:
Image
Code:

Code: Select all

magick original.jpg -colorspace RGB -define filter:window=Spline -distort resize 403x600 -colorspace sRGB fly.EWASplineJinc.png
Substituting the Quadratic window increases acutance, changes moire slightly, and is also pretty devoid of third halo. Both have fairly low moire.
Here is the backpack:
Image

Re: best downsampling method for DSLR photographs

Posted: 2012-09-22T12:43:00-07:00
by NicolasRobidoux
EWA quadratic B-spline smoothing windowed Jinc (3-lobe) is a better scheme than the Spline one, which definitely appears not to be as good as EWA LanczosSharp.
Maybe the quadratic B-spline smoothing windowed Jinc actually is better than EWA LanczosSharp when downsampling: insignificant second halo, slightly better moire suppression. Possibly a bit less perceptually sharp.
I'm particularly impressed with what it does with the backpack.
Image
Image

Code: Select all

magick BackPack.jpg -colorspace RGB -define filter:window=Quadratic -distort resize 1200x1200 -colorspace sRGB backpack.EWAQuadraticJinc.png
P.S. Yes, I think this may finally be a winner.

Re: best downsampling method for DSLR photographs

Posted: 2012-09-22T13:24:17-07:00
by NicolasRobidoux
... However, unless you want the added acutance (without second halo), good ol' -resize Mitchell (through linear light) is better in the artifacts department.
P.S. ...and EWA Robidoux appears to be about as sharp, moire free, has less halo, and is a lot cheaper to compute as EWA quadratic B-spline windowed Jinc 3-lobe, at least when downsampling.
So, I'll have to look into this very carefully.
P.S. ... but EWA quadratic B-spline windowed Jinc 3-lobe does have better moire suppression. EWA Robidoux is not as good in this respect. Basically, the new scheme is Mitchell with highlighted interfaces.
P.S. ... which may not be bad, because many many people USM when downsampling.

Re: best downsampling method for DSLR photographs

Posted: 2012-09-22T15:37:45-07:00
by NicolasRobidoux
@henrywho = Henry HO (and Luiz E. Vasconcellos = Pictus):
Whey you have a minute, could you have a look at EWA quadratic B-spline smoothing-windowed Jinc 3-lobe as a downsampling scheme?
I'm pretty impressed by its moire suppression. For example, it's about as sharp as EWA Mitchell, but it has almost no second halo, and it definitely suppresses moire better.
What do you think?
viewtopic.php?f=1&t=20992&start=225#p90392

Re: best downsampling method for DSLR photographs

Posted: 2012-09-23T08:03:37-07:00
by henrywho
NicolasRobidoux wrote:it's about as sharp as EWA Mitchell, but it has almost no second halo, and it definitely suppresses moire better.
viewtopic.php?f=1&t=20992&start=225#p90392
But EWA Mitchell is not sharp enough.......

Re: best downsampling method for DSLR photographs

Posted: 2012-09-23T18:27:45-07:00
by Pictus
NicolasRobidoux,
I agree with your finds, looks like you found the best neutral/balanced option... Image

Re: best downsampling method for DSLR photographs

Posted: 2012-09-23T21:53:25-07:00
by NicolasRobidoux
Henry and Luiz:
We seem to be in agreement RE: what it does, and what it does not.
Good.
And thank you.

Re: best downsampling method for DSLR photographs

Posted: 2012-09-23T22:53:01-07:00
by anthony
I have been looking at the graphs.

Window function (direct use of quadratic function, blurred to same support as a 3 lobe jinc)

Code: Select all

magick null: -filter -set option:filter:blur '%[fx:3.23832/1.5]' -define filter:verbose=1 -distort resize 200% null: > quad.dat
Jinc function (window using box)

Code: Select all

magick null: -define filter:window=box -define filter:verbose=1 -distort resize 200%  null: > jinc.dat
Quadratic windowed Jinc (multiplied the previous two)

Code: Select all

magick null: -define filter:window=quadratic -define filter:verbose=1 -distort resize 200% null: > quad-jinc.dat
normalize the data

Code: Select all

for i in *.dat; do
perl -i -ple '
    undef $first if /#/;
    next if /^$/ || /#/;
    ($x,$y)=split;
    $first=$y  if ! defined $first && $y > 0;
    $y /= $first; $_="$x\t$y";
    '  "$i"
done
Plot...

Code: Select all

gnuplot
    set grid
    plot "jinc.dat" with lines, "quad.dat" with lines, "quad-jinc.dat" with lines
Image

Now compare this to the default Robidoux... and RobidouxSharp

Code: Select all

magick null: -define filter:verbose=1 -distort resize 200% null: > robidoux.dat
magick null: -filter RobidouxSharp -define filter:verbose=1 -distort resize 200% null: > robidoux_sharp.dat
Image

It is certainally a bit different. I have not compared it to a normal Cylindrical Lanczos yet though. But as Lanczos uses a untapered window function (first lobe of Jinc) and this uses a Tapered one, you are essentially getting something like a 2 lobe Lanczos using a 3 lobed Jinc. More study is needed.

As the last positive lobe is so small (tappered windowing function), you can probably use a 3 lobe window support of -define filter:filter:win-support=3.23832 (as above) but limit the actual working support to just 2 -define filter:filter:lobe=2. The use of "win-support" setting has not been used much and may speed up things slightly by making the real (clipping limit) support smaller.

Re: best downsampling method for DSLR photographs

Posted: 2012-09-24T01:29:01-07:00
by henrywho
NicolasRobidoux wrote:P.S. ... which may not be bad, because many many people USM when downsampling.
I have always been advocating the direct use of EWA-Lagrange or even EWA-Catrom down-sampling instead of downsampling-then-USM. 8)

Re: best downsampling method for DSLR photographs

Posted: 2012-09-24T04:54:09-07:00
by NicolasRobidoux
anthony wrote:...It is certainally a bit different. I have not compared it to a normal Cylindrical Lanczos yet though. But as Lanczos uses a untapered window function (first lobe of Jinc) and this uses a Tapered one, you are essentially getting something like a 2 lobe Lanczos using a 3 lobed Jinc...
This was exactly my intention. (I can't pass anything by you.)
EWA 3-lobe Quadratic-windowed Jinc is the best 2-lobe method I've been able to put together! In terms of number of halos, this is exactly my description in The Recommendations.
The thin tails appear to help jaggies when upsampling and, especially, moire when downsampling.

Re: best downsampling method for DSLR photographs

Posted: 2012-09-24T04:57:42-07:00
by NicolasRobidoux
@Anthony:
And yes, maybe it would be a good thing to chop the filter off earlier.
I do believe that the thinnest part of the tail contributes something. But at this point, I have no proof.

Re: best downsampling method for DSLR photographs

Posted: 2012-09-24T05:50:21-07:00
by NicolasRobidoux
anthony wrote:...As the last positive lobe is so small (tappered windowing function), you can probably use a 3 lobe window support of -define filter:filter:win-support=3.23832 (as above) but limit the actual working support to just 2 -define filter:filter:lobe=2. The use of "win-support" setting has not been used much and may speed up things slightly by making the real (clipping limit) support smaller.
You and I had the exact same idea.
However, I think that the minuscule third lobe contributes something in practice.
For one thing, this third lobe grabs a lot of pixels, because it is the "edge of the pizza".
For another, it ensures that the overall filter is C^2 (twice continuously differentiable), which very few filters are. It has gradients which are themselves continuously differentiable. Specificially, the result has a well defined curvature tensor everywhere.
-----
In my original version of "The Recommendations" (yes, I know it's juvenile to capitalize them; I am easily amused), I left a "gap" in the upsampling section, between the LanczosSharp, LanczosRadius3 and Ginseng 3 on the one hand, every one with a significant second halo, and EWA quadratic B-spline smoothing and EWA cubic B-spline smoothing, which have no halo whatsoever. The reasons is that, when upsampling, I truly do not find any of the 2-lobe filters to be really good. (Tensor Mitchell comes pretty close when HDRI is on. EWA Robidoux is not bad.)
EWA quadratic B-spline windowed Jinc 3-lobe fills this gap: on paper, it has 3-lobes. In practice, it has two. And yet it is good at moire suppression, without being overly blurry. And, AFAIK, it has less jagginess, given how sharp it is, than any of the 2-lobe filters.
As Luiz Vasconcellos put it, a good neutral scheme.
P.S. Correction: Because the quadratic B-spline is only C^1, and one of the breaks is not at a common root with Jinc, the filter is actually only C^1, like most of the good ones.

Re: best downsampling method for DSLR photographs

Posted: 2012-09-24T06:00:44-07:00
by NicolasRobidoux
henrywho wrote:
NicolasRobidoux wrote:... I have always been advocating the direct use of EWA-Lagrange or even EWA-Catrom down-sampling instead of downsampling-then-USM. 8)
Indeed, you and Fred may have a point here. I just can't stand the artifacts.
On the other hand, I've not compared the artifacts of typical USM VS the artifacts of using EWA-Lagrange.