如何解决给定 3d 函数上的点 f(x,y,z) 和采样点 x,y 找到函数存在的 z
我有一组 3d 点的函数值,即我知道 f(x,y,z)
。现在我想在一组不同的点 (x',y')
处对这个函数进行采样。但我不知道第三个坐标 z'
。我需要首先为每个点 z'
找到函数存在的 nan
的值(不是 (x',y')
),然后在这一点找到函数的值,即 f(x',y',z')
.我的代码在 python 中。我尝试使用 scipy.interpolate.griddata()
但我还需要给出一个 z'
值的网格。因此我被卡住了。是否有可能做到这一点?如果是,如何?任何其他建议也表示赞赏
import numpy
import scipy.interpolate
image = numpy.array([[246,50,101],[116,1,113],[187,110,64]])
depth = numpy.array([[5,3,5],[20,25,3],[45,23,11]])
height,width = image.shape
iy = numpy.array([[1.5,0.2,2.3],[1.6,0.1,2.8],[2.4,2.6,2.5]])
ix = numpy.array([[0.1,2.1,1.7],[1.2,2.3,0.7],[0.1,1.9,2.7]])
indices = numpy.stack([ix,iy,depth],axis=2)
y1 = numpy.array(range(height))
x1 = numpy.array(range(width))
# Find z1 such that image(y1,x1,z1) exists.
代码中变量与问题描述中的关系
-
f(x,z)
是image
变量 -
(x,z)
是indices
- 因此
f(indices[1,0],indices[1,1],2]) = image[1,0]
-
(x',z')
是(x1,y1,z1)
。我想找到z1
使得image[y1,x1] = f(indices[y1,indices[y1,2])
存在。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。