license: GPL v2
SplineResize contrains two kinds of spline based resizers:
The first ones are the (cubic) spline based resizers from Panorama tools that fit a spline through the sample points and then derives the filter kernel from the resulting blending polynomials. See this thread for the details. Spline100Resize (using 10 sample points) and Spline144Resize (using 12 sample points) are added here. Other ones are available in AviSynth itself.
The second ones are natural cubic splines that use the kernel itself as a spline. The theory can be found here.
Spline100Resize
(clip clip, int target_width, int
target_height [, float src_left, float src_top, float
src_width, float src_height])
Spline144Resize
(clip clip, int target_width, int
target_height [, float src_left, float src_top, float
src_width, float src_height])
SplineResize
(clip clip, int target_width, int
target_height, int taps = 4 [, float src_left, float src_top, float
src_width, float src_height])
The number of sample points is given by 2*taps (yes i abused the meaning of taps to keep the notation inline with AviSynth's documentation), where 1<=taps<=100.
clip = ... Spline100Resize(clip, 640, 480) SplineResize(clip, 640, 480, taps=6)
As a follow up to Cubic Spline Interpolation (authors: Sky McKinley and Megan Levine). We start with equation 28 with h=1, n=2*taps+1, y(j)=0 and y(taps)=1. This results in the following symmetric system:
A*m = f
with A = [4 1 0 0 ... ; 1 4 1 0 ... ; 0 1 4 1 ... ; ... ; ... 0 1 4], m = [m(2); m(3); ...; m(2*taps)] and f = 6*[0; 0; ... ;1; -2; 1; ...; 0; 0].
The solution of the system can be obtained in the following way (with x(0)=M(1)=0, x(1)=M(2),..., x(2*taps-1)=M(2*taps), x(2*taps)=M(2*taps+1)=0):
w(0)=4, w(j) = 4 - 1/w(j-1) for j=1..2*taps-1
z(0) = f(0)/w(0), z(j) = (f(j) - z(j-1))/w(j) for j=1..2*taps-1
x(0)=0, x(2*taps)=0, x(j) = z(j) - x(j+1)/w(j) for j=2*taps-1..1
This will follow after doing a LU decomposition. The coefficients are obtained from (j=1..2*taps, y(0)=...=y(2*taps+1)=0, y(taps)=1)
a(j) = (m(j+1) - m(j))/6
b(j) = m(j)/2
c(j) = (y(j) - y(j-1)) - (m(j+1) + 2*m(j))/6
d(j) = y(j-1)
Note that as as a result of the symmetry: a(j) = a(2*taps-j) (for b(j), c(j) and d(j) similar). As a result the second set of equations (j=taps..2*taps) is used for the resizer.
v0.2, 20st June 2009
v0.1, 1st June 2009