pythonimage-processinginterpolationspline

Perform Cubic Spline Interpolation in an image Python


Let's say, I have frames (50) of images (656, 875, 3) - (W x H x C). So, the final input is an array with shape (50, 656, 875, 3). If my input points have dimensions (24, 2) - (x, y), how would I perform cubic spline interpolation in every frame?

To clarify what I want to achieve, I have topographic maps of brain like the above image A topographic map, which has been created from EGG. On this map, there are some points under the brain where the sensors of the EGG have been placed like the second one image Second topographic map with sensors. Every frame is a frequency and I want to produce an EGG cube using the cubic spline interpolation.


Solution

  • It's a little unclear what you're asking, as cubic splines could be used for several things in image processing:

    Since you have a series of points, I'm assuming you want to do the curve fitting. Take a look at the SciPy cubic spline docs. After you have the polynomial, you could step through the breakpoints and plot each pixel to the frame.

    Edit: If you want to do a 3D cubic spline (forming a 3D surface), it will require the points to be in the same plane, and the height of the surface represent magnitude at each point. There are some examples of this using scipy.interpolate.Rbf in StackEchange: Spline Interpolation in 3D in Python. If your points are not in the same plane, you could forgo the cubic spline and use a gaussian blur from the pillow library.