Nag*_*S N 6 python interpolation scipy weighted-average
我正在尝试重建我知道值是浮点像素位置的图像。我正在使用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, newshape=(height*width,))
warped_image = scipy.interpolate.griddata(trans_pos_flat, frame1_flat, (x2d, y2d))
Run Code Online (Sandbox Code Playgroud)
在griddata()我也想传递深度。对于例如,indices[0,1]与indices[1,1]点像素的附近(0,2)。因此,image这些位置处的值将用于插入 处的值(0,2)。但是,由于image[1,1]具有更高的权重 ( depth),我希望最终强度 atwarped_image[0,2]主要受image[1,1]than 的影响image[0,1]。我怎样才能做到这一点?