import numpy, scipy
from scipy import interpolate
kernelIn = numpy.array([[0, -2, 0], [-2, 11, -2], [0, -2, 0]])
inKSize = len(kernelIn)
outKSize = 5
kernelOut = numpy.zeros(outKSize, numpy.uint8)
x = numpy.array([0, 1, 2])
y = numpy.array([0, 1, 2])
z = kernelIn
xx = numpy.linspace(x.min(), x.max(), outKSize)
yy = numpy.linspace(y.min(), y.max(), outKSize)
newKernel = interpolate.RectBivariateSpline(x, y, z, kx=2, ky=2)
kernelOut = newKernel(xx, yy)
print(kernelOut)
Scipy interpolation how to resize/resample 3x3 matrix to 5x5?