类似于scipy.interpolate.griddata? [英] analogy to scipy.interpolate.griddata?
问题描述
我想对给定的3D点云进行插值:
I want to interpolate a given 3D point cloud:
我查看了scipy.interpolate.griddata,结果正是我所需要的,但是据我了解,我需要输入"griddata",其含义类似于x = [[0,0,0],[1,1,1],[2,2,2]]
.
I had a look at scipy.interpolate.griddata and the result is exactly what I need, but as I understand, I need to input "griddata" which means something like x = [[0,0,0],[1,1,1],[2,2,2]]
.
但是我给定的3D点云没有这种网格外观-x,y值的行为不像网格-无论如何,每个x,y值只有一个z值.*
But my given 3D point cloud don't has this grid-look - The x,y-values don't behave like a grid - anyway there is only a single z-value for each x,y-value.*
那么对于不在网格点云中的scipy.interpolate.griddata,还有其他替代方法吗?
So is there an alternative to scipy.interpolate.griddata for my not-in-a-grid-point-cloud?
* 无网格外观"表示我的输入看起来像这样:
*edit: "no grid look" means my input looks like this:
x = [0,4,17]
y = [-7,25,116]
z = [50,112,47]
推荐答案
这是我用于此类操作的函数:
This is a function I use for this kind of stuff:
from numpy import linspace, meshgrid
def grid(x, y, z, resX=100, resY=100):
"Convert 3 column data to matplotlib grid"
xi = linspace(min(x), max(x), resX)
yi = linspace(min(y), max(y), resY)
Z = griddata(x, y, z, xi, yi)
X, Y = meshgrid(xi, yi)
return X, Y, Z
然后像这样使用它:
X, Y, Z = grid(x, y, z)
这篇关于类似于scipy.interpolate.griddata?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!