I am trying to reconstruct an image for which I know the values are floating-point pixel positions. I'm using scipy.interpolate.griddata()
to interpolate the values at each integer location and reconstruct the image. However, I also want to provide weights to all the known points I have. Is it possible to do this in griddata()
. If yes, how can I do this?
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))
In griddata()
I want to pass the depth as well. For eg, indices[0,1]
and indices[1,1]
point to the neighborhood of pixel at (0,2)
. So, image
value at these positions will be used to interpolate the value at (0,2)
. However, since image[1,1]
has higher weight (depth
), I want the final intensity at warped_image[0,2]
to be mainly influenced by image[1,1]
than image[0,1]
. How can I achieve this?