If speed matters (and I imagine it does), I would do EWA filtering with a Keys cubic kernel: They are so simple that they can be evaluated without a look up table: the slowest part of it in the evaluation of each weight is the computation of a square root, which is pretty fast nowadays.
For example, the unnormalized weights for the "sharpest" "accurate" piecewise cubic EWA (discussed at
viewtopic.php?f=22&t=19823) can be evaluated as follows once the square of the distance to the relevant pixel has been determined (rsq below):
Code: Select all
if rsq >= 4 then
w = 0
else
r = sqrt(rsq)
if rsq <= 1 then
w = 1 + ( ((-56*sqrt(2)-27)/46) + ((42*sqrt(2)+3)/46) * r ) * rsq
else
rm2 = r + -2
w = ( (1/2) + ((-14*sqrt(2)-1)/46) * r ) * rm2 * rm2
endif
endif
which boils down to 1 square root, 3 multiplications and 2 additions in the longest branch. (On some chips it may be better to reorganize the branching differently.)
I can provide similar simple formulas for the other cubic splines.
P.S. Using constant folding and the fact that multiplicative constants don't matter when filtering, I can get rid of one multiplication.