Skip to content
Advertisement

Interpolation of points along the spline using scipy.interpolate.splrep

I’m working on the task of interpolating the points along the lanes in the images. A sample image with annotated points(image not from the actual dataset and spacing between the point is also not actual) is included here.

I’m trying to use slprep from scipy and below are the steps I’m taking.

JavaScript

My current observations are:

  1. When I plot the pixel marking of (interpolated_x and query_y) the resulting coordinates does not lie in between the marking of input (x and y) coordinates.

My questions are:

  1. can someone tell me what I’m doing wrong?

  2. How to define knots argument from splrep so that the interpolated spline passes through maximum input points??

  3. Most of the related threads I see use the interpolation function to evaluate y = f(x) where x is known and y is to be interpolated and I’m using the interpolation function to evaluate x = f(y). Is this causing any problem??

Advertisement

Answer

I hope I understood your questions.
1 & 3: You are interpolating (x,y) data with (y’,x’) points. This will not work, as you suggested in the 3rd subquestion. 2: Please see sample code if it is what you looking for:

JavaScript

The last plot looks like

The output

where red crosses are obviously initial points, and blue curve is the interpolated data.

Linked sorting are taken from Sort array’s rows by another array in Python.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement