[cairo] image downsampling quality
tweenk.pl at gmail.com
Thu Jan 2 13:16:45 PST 2014
2014/1/2 Søren Sandmann <sandmann at cs.au.dk>:
> Krzysztof Kosiński <tweenk.pl at gmail.com> writes:
>>> I think it's bilinear, which means if you are reducing to less than 50%, it
>>> misses pixels.
>>> There's been tons of talk and patches to fix this in pixman over the years.
>>> I'm not sure what the current status is.
>> The current trunk is fixed, and uses Lanczos3 downsampling for
> If I'm reading the code in cairo-image-source.c right, then the 'BEST'
> case is missing a break so that it falls through to GAUSSIAN and then to
> default, which then seems to use a box filter for sampling and a
> bilinear filter for reconstruction.
That's obviously a bug.
> It also looks like, if a "break" were to be added, that the BEST filter
> would use LANCZOS3 for both sampling and reconstruction which would
> pointlessly make the filter bigger (and therefore slower) in the common
> cases of a pure upscaling or downscaling.
Currently the code creates a convolution filter if any of the
dimensions (x or y) is being shrunk. Otherwise it uses the standard
Pixman paths for sampling, which do not use convolution filtering.
> (It can make sense to use a box filter for both reconstruction and
> sampling because a box filter is such a poor filter, but Lanczos3 is a
> good enough filter that it's safe to pair it with Impulse as long as the
> transformation is a pure downscaling or upscaling).
Impulse sampling is always used when the given dimension is upscaled.
For downscaling, it seems that Lanczos3 is used for both sampling and
reconstruction. Should Lanczos3 sampling be used together with box
reconstruction in that case?
More information about the cairo