在python中绘制3D表面作为高质量图像

时间:2018-06-17 11:43:56

标签: python image python-2.7 plot 3d

我正在使用python 2.7。 我有一个numpy形状的数组(1024,1024),包含表面中每个点的高度值(米)。我还有关于图像的实际尺寸的信息(长度(米))。我对数组重塑很实用,但是我不知道我正在寻找的解决方案需要哪个输入。

我需要的是一个模块,它将高质量的图像绘制为我所附着的图像,具有相似的颜色和正确的比例(每个轴1:1) 图像必须是透视的,并且必须从代码中设置“相机”的位置。颜色条应该是可见的,与图像中显示的相反。图像必须保存在文件中。 我尝试用matplotlib实现类似的东西,但质量非常低,而且我的使用不实用。以下是我在matplotlib中尝试的代码,结果很差。

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm


fig = plt.figure()
ax = Axes3D(fig)

# the array:
Z
# the real length of the size of the image
size_length
X_res, Y_res = np.indices(Z.shape)
X = X_res * size_length
Y = Y_res * size_length

surf = ax.plot_surface(X, Y, Z, cmap=cm.Spectral, antialiased=False)

fig.colorbar(surf, shrink=0.5, aspect=5)
ax.set_proj_type('persp')
ax.set_xlabel('x - Length in micron')
ax.set_ylabel('y - Length in micron')
ax.set_zlabel('z - Heigth in micron')
max_lim = size_length
ax.set_xlim3d(0, max_lim)
ax.set_ylim3d(0, max_lim)
ax.set_zlim3d(0, max_lim)

plt.show()

Reference image

0 个答案:

没有答案