[SciPy-User] evaluating B-Splines made with scipy.signal.cspline2d?

Kay F. Jahnke _kfj at yahoo.com
Wed Nov 9 12:19:33 EST 2011


I did have lines over 80 chars after all...

Zachary Pincus <zachary.pincus <at> yale.edu> writes:

> This doesn't answer your specific question, but look at
> scipy.ndimage.map_coordinates()
> for general-purpose spline interpolation of regularly-spaced (e.g. image)
> data. If you want to repeatedly interpolate the same data, you can get the
> spline coefficients with:
> scipy.ndimage.spline_filter() and pass them to map_coordinates()
> with the "prefilter=False" option.

Thank you very much for your helpful hint. I tried out the code you suggested
and it seems to do just what I want. It seems to me that I can also process the
coefficient matrix I get from signal.cspline2d() with ndimage.map_coordinates()
as well as being able to have ndimage.spline_filter() generate the coefficients,
though the coefficient matrices the two routines provide aren't identical.

The resulting program is fast; both the calculation of the coefficient matrix
for a 512X512 image and the interpolation of an equally-sized output took
under a second on my system.

> It is curious that while scipy.signal has cspline1d() and cspline1d_eval(),
> there is no cspline2d_eval() function... hopefully someone else can weight
> in on what's going on here.

curious indeed, but ndimage seems to solve the problem. Still
signal.cspline2d_eval() should be put on the wish-list :-)





More information about the SciPy-User mailing list