首页 > 解决方案 > 如何在张量流中完全执行二维插值?

问题描述

我已经使用 scipy.interpolate 中的 RectBivariateSpline 方法成功地在 python 中执行了 2d 插值。但是,它是在 numpy 数组上执行的。我想仅使用 tensorflow 在张量上执行它。

这就是我现在所拥有的:如果都是 numpy 数组,它就可以工作。但是,我很难在 tensorflow 中重写它。

x_old = np.arange(0,256)
y_old = np.arange(0,256)

#x = tensor of shape [256,256]
#y = tensor of shape [256,256]
#in_im = tensor of shape [256,256,3]
#out_im = tensor of shape [256,256,3]

for d in range(0,3):
    interpf = RectBivariateSpline( x_old, y_old, in_im[:,:,d])
    out_im[:,:,d] = interpf.ev(x[:,:], y[:,:])

标签: pythontensorflow2dinterpolation

解决方案


tf.image 中的调整大小运算符可能是您正在寻找的,例如 tf.image.resize_bicubic ( https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/image/resize_bicubic )


推荐阅读