Python 3D interpolation speedup
问题 I have following code used to interpolate 3D volume data. Y, X, Z = np.shape(volume) xs = np.arange(0, X) ys = np.arange(0, Y) zs = np.arange(0, Z) points = list(zip(np.ravel(result[:, :, :, 1]), np.ravel(result[:, :, :, 0]), np.ravel(result[:, :, :, 2]))) interp = interpolate.RegularGridInterpolator((ys, xs, zs), volume, bounds_error=False, fill_value=0, method='linear') new_volume = interp(points) new_volume = np.reshape(new_volume, (Y, X, Z)) This code takes about 37 seconds to execute on