Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
529 views
in Technique[技术] by (71.8m points)

python - Pass weights to scipy.interpolate.griddata() function

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...