【发布时间】:2020-06-20 18:19:01
【问题描述】:
我正在尝试使用带有 matplotlib 的线框将图像的 3D 表示为表面。
ig= mpimg.imread('testIMG.png');
X = np.linspace(0,len(ig[0]),len(ig[0])); #List of discrete x values
Y = np.linspace(0,len(ig[1]),len(ig[1])); #List of discrete y values
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
#Plot the wireframe
#I want to plot the image as f(x,y) and I can't understand why wireframe won't let me
ax.plot_wireframe(X, Y, ig[:,:,2], rstride=10, cstride=10)
plt.show()
imread 函数为我提供了一个 MxNx3 数组,其中包含 M 行、N 列以及矩阵中每个点的 RGB 值。我不明白如何使用线框正确绘制该数据。这些 z 值不是我所期望的(棋盘模式),而是在 0 和 1 之间交替的 y=x 线。
我需要在这里做什么?我想要一系列 3D 棋盘格图案的长方体。 Image of what I have currently
【问题讨论】:
标签: python image matplotlib 3d