Reputation: 45
I'm having trouble connecting the mathematical concept of spline interpolation with the application of a spline filter in python. My very basic understanding of spline interpolation is that it's fitting the data in a piece-wise fashion, and the piece-wise polynomials fitted are called splines. But its applications in image processing involve pre-filtering the image and then performing interpolation, which I'm having trouble understanding.
To give an example, I want to interpolate an image using scipy.ndimage.map_coordinates(input, coordinates, prefilter=True)
, and the keyword prefilter
according to the documentation:
Determines if the input array is prefiltered with
spline_filter
before interpolation
And the documentation for scipy.ndimage.interpolation.spline_filter
simply says the input is filtered by a spline filter. So what exactly is a spline filter and how does it alter the input data to allow spline interpolation?
Upvotes: 3
Views: 844
Reputation: 6946
I'm guessing a bit here. In order to calculate a 2nd order spline, you need the 1st derivative of the data. To calculate a 3rd order spline, you need the second derivative. I've not implemented an interpolation motor beyond 3rd order, but I suppose the 4th and 5th order splines will require at least the 3rd and 4th derivatives.
Rather than recalculating these derivatives every time you want to perform an interpolation, it is best to calculate them just once. My guess is that spline_filter is doing this pre-calculation of the derivatives which then get used later for the interpolation calculations.
Upvotes: 1