2D interpolation of a large irregular grid to a regular grid

I have a 2048x2048 mesh of irregular data zi = f(xi, yi) which are essentially three independent sets of 2048 real values. I need to smoothly interpolate (possibly a bicubic spline) into a regular grid with wi = f(ui, vi) where ui and vi are integer values ​​from 0 to 2047.

I tried griddata, which seems to work well on images smaller than 1000x1000, but explodes when it reaches 1500x1500 (qhull memory errors for Delaunay mesh, obviously). I looked at some ndimage functions, namely geometric_transform , RectBivariateSpline and map_coordinates , but they all seem to accept regularized data as input. I could have missed something and just implemented it wrong, though too!

I am trying to use Python / SciPy to do what this Matlab script I did using tformarray and makeresampler . Any suggestions as to which function I can use to process this large dataset? Thanks!

+6
source share
1 answer

I tried to reproduce your mistakes without success. Are you on a 32-bit system? I had problems with scipy / numpy and large arrays, so they switched to 64 bits, and since then they have had no problems.

Here is the code I used to try to reproduce your error (it will not bring anything useful, but should at least experience the same errors):

 y,x=indices([2048,2048],dtype='float64') z = randn(2048,2048) yr = y + randn(2048,2048) xr = x + randn(2048,2048) zn = griddata(xr.ravel(),yr.ravel(),z.ravel(),x,y) zl = griddata(xr.ravel(),yr.ravel(),z.ravel(),x,y,interp='linear') 

It works on my machine.

If you cannot run the 64-bit version of python (which can be difficult depending on which OS you are using), can you split the 2048x2048 grid into 4 1024x1024 grids?

+2
source

Source: https://habr.com/ru/post/895081/


All Articles