import numpy as np
import matplotlib.pyplot as plt
# generate some data
ax = np.arange(-9, 10)
X, Y = np.meshgrid(ax, ax)
Z = X ** 2 + Y ** 2
# normalize the data and convert to uint8 (grayscale conventions)
zNorm = (Z - Z.min()) / (Z.max() - Z.min()) * 255
zNormUint8 = zNorm.astype(np.uint8)
# plot result
plt.figure()
plt.imshow(zNormUint8)
1
多谢你们 . 我刚刚编写了自己的代码来进行插值 . 但我的想法来自你的 . 感谢@asaflotz和@Paul Panzer .
2 回答
让我们假设X,Y排列成它们将形成一个网格(为了构建一个矩形图像,这是必须的) . 从那里这很容易:
多谢你们 . 我刚刚编写了自己的代码来进行插值 . 但我的想法来自你的 . 感谢@asaflotz和@Paul Panzer .
事情就是在我的场景中,点 Cloud 中的点数排列不好 . 两个附近点之间的间隔不均匀 . 直接使用网格是不可能的 . 所以我在Scipy.Interpolate中选择了一个非结构化的方法,根据不同的用例,可以使用许多实用的方法 . 我的代码是Scipy.Interpolate.griddata中示例的修改版本 .
注意到在griddata中,可以根据您的场景应用类似 'linear', 'nearest', 'cubic' 的方法 . 这是生成的灰度高程图像 .
最后,我的问题基本上已经解决了 . 如果您有任何好的想法或困惑,请对此帖发表评论 . 谢谢大家!
罗文