如何解决如何在由 Python 中的 3D 点云组成的形状的顶面上存储点?
我有一个表示 3D 形状的 3D 点云(下图)。我想将 3D 形状的顶面投影到 2D 平面上以创建图像。下面只有蓝色和红色区域的图像是我想要的。如果我只是将所有 Z 值投影到 2D 平面上,我会得到一个图像,其中包含对应于形状顶部和底部(以及侧面)的 Z 值之间的重叠,如下面扭曲的图像映射所示。
下面是我尝试创建图像映射的代码,但在绘制底部和边缘的点被过滤掉的位置之前需要一个步骤。有什么想法吗?
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import griddata
#load point cloud data: array of size NPoints*3
verts = np.load("arrayOfPoints_shape_NPointsX3.npy")
'''
#Add code here to store only the points from the top surface of the shape
'''
#set up 2D grid for image
X = np.linspace(0,760,256)
Y = X
gridX,gridY = np.meshgrid(X,Y)
#interpolate to grid
interpolatedImage = griddata(verts[:,0:2],-1*verts[:,2],(gridX,gridY),method='linear',fill_value=0)
plt.figure(2,figsize=(10,10))
plt.imshow(interpolatedImage,cmap='jet')
plt.colorbar()
plt.show()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。