Given points on a 3d function, f(x,y,z), and sampling points x,y find z where the function exists

Viewed 104

I have the function values at a set of 3d points i.e. I know f(x,y,z). Now I want to sample this function at a different set of points (x',y'). But I don't know the third coordinate z'. I need to first find the values of z' where the function exists (not nan) for every point (x',y') and then find the value of the function at this point i.e. f(x',y',z'). My code is in python. I tried using scipy.interpolate.griddata() but I need to give a grid of z' values as well. And hence I'm stuck. Is it possible to do this? If yes, how? Any other suggestions are also appreciated

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.

Relation between variables in code and in problem description

  1. f(x,y,z) is the image variable
  2. (x,y,z) is indices
  3. Thus f(indices[1,0,0],indices[1,0,1],indices[1,0,2]) = image[1,0]
  4. (x',y',z') is (x1,y1,z1). I want to find z1 such that image[y1,x1] = f(indices[y1,x1,0],indices[y1,x1,1],indices[y1,x1,2]) exists.
0 Answers
Related