[cairo] Concerns about using filters for downscaling

Owen Taylor otaylor at redhat.com
Tue Mar 25 19:17:24 PDT 2014


On Wed, 2014-03-26 at 00:34 +0100, Krzysztof Kosiński wrote:
> 2014-03-25 22:18 GMT+01:00 Owen Taylor <otaylor at redhat.com>:
> > On Tue, 2014-03-25 at 16:39 -0400, Owen Taylor wrote:
> >
> >> The other consideration is things look actually like, of course.
> >> I've put up samples of the different downscaling methods on different
> >> images at:
> >>
> >>  http://fishsoup.net/misc/downscaling/samples.html
> >
> > Turned out that some box filtering crept into the Mipmap/Trilinear
> > samples - I've fixed that now, but if you looked at the images
> > immediately after I posted the link and drew any conclusions, you should
> > reload the page and look again.
> 
> Two comments:
> 
> 1. For interactve use, I think that any method except NEAREST has
> acceptable quality, while for non-interactive use it is clear that
> Lanczos3 gives excellent quality even for pathological images. There
> should be a way to use both one of the 'not perfect but reasonably
> fast' methods and full Lanczos3.

I'm not necessarily convinced that the Lanczos3/Lanczos3 filter is
really necessary to get excellent results on when downscaling. People
resize their photos in the GIMP all the time using the default Cubic
(i.e. Impulse/Cubic) interpolation. Playing around with
pixman/demos/scale, it's hard for me to see any significant differences
in the window screen demo going from Cubic to Lanczos.

And this is not a trivial difference. The size of Impulse/Cubic is
ceil(4*s) as compared to ceil(6*s + 6).

 s=1.1: 13x13 / 5x5 = 6.7
 s=3:   24x24 / 12x12 = 4
 s=5:   36x36 / 20x20 = 2.2

So leaving aside what we want to do for this release, long term I don't
see using a huge filter for BEST unless we can demonstrate differences.
The faster BEST is, the more useful it is.

> 2. For "Window Screen", it looks like the 1 / 1.1 scaling example for
> Lanczos3 shows the same Moire pattern as NEAREST and box filtering.
> This may be due to the subsampling always being set to 1x. Can you
> regenerate this image with a larger value e.g. 4x? (Those are the last
> two parameters to the Pixman call that creates the convolution.)

Good catch! - I said myself in the first email in this thread:

 When the filters are created, the number of subsample bits passed to
 pixman is always 1 (even for the huge BEST filters) This produces
 artifacts that drown out the choice of filter,and may result in results
 worse than bilinear filtering for some scale factors.

But I had set subsample bits set back to 1 cairo so that filter
generation wasn't distorting the results of timing. (*)

I've now updated the images to allow selecting between 1 bit and 4 bits
of subpixel precision. (For more exploration of different bit values see
pixman/demos/scale - there's a limit to how much pre-rendered image data
I want to put on my server :-)

- Owen

(*) with a fixed subsample of 4, generating 256 copies of the downscale
    filter gets quite slow for large downscales. But you can see that
    there's no real visible difference when the filter is that big - the
    subsampling should depend on the scaling factor.




More information about the cairo mailing list