I have some data points in an irregularly-spaced 2d grid which I'd like to interpolate onto a regular grid. For example, imagine the source data comes from a fisheye camera: [![](https://i.stack.imgur.com/epKHH.jpg)](https://i.stack.imgur.com/epKHH.jpg)  

(source: [starizona.com](https://starizona.com/acb/basics/optics/distortion.jpg))

**Examples of irregular source grids. Note... these are just examples - in general source data may be distorted in different ways too - but still come from a grid.**

```
# Source Data
x_src  # A (n_src_rows, n_src_cols) array of x-coordinates of points
y_src  # A (n_src_rows, n_src_cols) array of y-coordinates of points
       # (x_src, y_src) form an irregular grid.  i.e. if you were to plot the lines connecting neighbouring points, no lines would ever cross.
f_src  # A (n_src_rows, n_src_cols) array of values.

# Interpolation Points: 
x_dst  # An (n_dest_cols) sorted array of x-coordinates of columns in a regular grid
y_dst  # An (n_dest_rows) sorted array of y-coordinates of rows in a regular grid.

# Want to calculate:
f_dst  # An (n_dest_rows, n_dest_cols) array of interpolated data on the regular grid defined by x_dst, y_dst

```

Thus far, I've been using [scipy.interpolate.griddata](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.griddata.html), and flattening my source points into a 1D array, but it's a bit slow, because it takes no advantage of the grid structure of the source data points (only the destination data points). It also interpolates in regions that are not inside adjacent source grid points (this happens if the boundaries of the source grid are concave (as in the left figure).

Is there a function in SciPy/opencv or some similar library that interpolates efficiently when the source data comes in an irregularly-spaced grid?