将权重传递给 scipy.interpolate.griddata() 函数

问题描述

我正在尝试重建我知道其值为浮点像素位置的图像。我使用 scipy.interpolate.griddata() 在每个整数位置插入值并重建图像。但是,我也想为我拥有的所有已知点提供权重。是否可以在 griddata() 中执行此操作。如果是,我该怎么做?

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,it],axis=2)
y1d = numpy.array(range(height))
x1d = numpy.array(range(width))
x2d,y2d = numpy.meshgrid(x1d,y1d)

indices_flat = numpy.reshape(indices,newshape=(height*width,2))
image_flat = numpy.reshape(image,))
warped_image = scipy.interpolate.griddata(trans_pos_flat,frame1_flat,(x2d,y2d))

griddata() 中,我也想传递深度。例如,indices[0,1]indices[1,1] 指向(0,2) 处的像素邻域。因此,这些位置的 image 值将用于插入 (0,2) 处的值。但是,由于 image[1,1] 具有更高的权重 (depth),因此我希望 warped_image[0,2] 处的最终强度主要受 image[1,1] 而非 image[0,1] 的影响。我怎样才能做到这一点?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)