[英]How to get interpolated array values in numpy / scipy
I was wondering how I could get the interpolated value of a 3D array. 我想知道如何获得3D数组的插值。 I am trying to get the value at for example position: (1.4, 2.3, 4.2) of a 3d array.
我试图在3d数组的位置(例如1.4、2.3、4.2)获得值。 How can I get the interpolated value?
如何获得内插值?
counterX = 1.5
counterY = 1.5
counterZ = 1.5
for x in range(0, length)
for y in range(0, length)
for z in range(0, length)
value = img[counterX, counterY, counterZ]
counterZ = 0
counterY = 0
counterX, counterY and counterZ are float values rather than integers. counterX,counterY和counterZ是浮点值,而不是整数。 However I cannot css them int(...) since my results need to be very exact.
但是,由于我的结果必须非常准确,因此无法将它们int(...)进行css处理。 Therefore I thought interpolation would be the best solution.
因此,我认为插值将是最好的解决方案。
I am not sure what is exactly your problem. 我不确定您到底是什么问题。
Would you like to create an interpolated array from some observed values ? 您想根据一些观测值创建一个插值数组吗? Then I would personnally recommend to use a kriging model, pyKriging seems to do that but I never used it personnally.
然后我个人建议使用kriging模型,pyKriging似乎可以做到这一点,但我从来没有亲自使用过。
Then you could create a function (using the prediction model built through kriging) taking 3 arguments counterX, counterY and counterZ and just evaluate the prediction in any positions. 然后,您可以创建一个函数(使用通过克里金法建立的预测模型),使用3个参数counterX,counterY和counterZ并仅在任何位置评估预测。
Just go for trilinear Interpolation as described here: https://en.wikipedia.org/wiki/Trilinear_interpolation 只需按照此处所述进行三线性插值: https : //en.wikipedia.org/wiki/Trilinear_interpolation
For your example this would be: 对于您的示例,这将是:
C00 = (1,2,4)*0.6 + (2,2,4)*0.4
C01 = (1,3,4)*0.6 + (2,3,4)*0.4
C10 = (1,2,5)*0.6 + (2,2,5)*0.4
C11 = (1,3,5)*0.6 + (2,3,5)*0.4
C0 = C00*0.8 + C10*0.2
C1 = C01*0.8 + C11*0.2
C = C0*0.7 + C1*0.3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.