[Pixman] [cairo] Image resampling [PATCH 0/6]
spitzak at gmail.com
Tue Nov 27 12:09:14 PST 2012
Siarhei Siamashka wrote:
> Bilinear scaling uses weighted average of 2 pixels (in one direction),
> with weights calculated on the go. Separable convolution uses weighted
> average of N pixels, with weights obtained by table lookups. Both use
> subpixel positions (7 phase bits or 128 phases for current bilinear
> implementation) to lookup or calculate weights. Bilinear filter is
> naturally a subset of separable convolution.
Also note that the separable filters need different "widths" as well as
different phases. This is the distance from the center to the first 0
crossing in a sync filter, note that the non-zero part of the filter is
several times the width (3 for a triangle, 5 for most, and 7 for
lancos3). If the image is being scaled by 1/N the width is max(1,N).
There probably should be a pre-calculated table of all combinations of
width and phase. The minimum width is 1, but there will have to be a
maximum chosen. Pixman would use the maximum if a larger size is wanted,
which would mean that scales smaller than a certain value would be
noisy. However if Cairo prescales by a power of 2 then the maximum scale
may be 4.
In Nuke the pre-calculated table is just a very wide filter (I think the
width is 64) and that is the maximum filter size. Smaller filters and
different offsets are chosen by subsampling this large filter at even
intervals (Nuke chose the closest sample, but bilinear sampling would be
better). The table was "normalized" so that the width of 1 produced
samples that sum to 1, all larger filters needed to a normalization
factor calculated by doing 1/sum of the samples.
More information about the Pixman