python——点云可视化

戏子无情 提交于 2020-03-02 11:29:06

点云的特征可视化代码样例:

#### 特征可视化
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np

points = np.loadtxt('data.txt')
skip = 20   # Skip every n points

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
point_range = range(0, points.shape[0], skip) # skip points to prevent crash
x = points[point_range, 0]
y = points[point_range, 1]
z = points[point_range, 2]
ax.scatter(x,   # x
           y,   # y
           z,   # z
           c=z, # height data for color
           cmap='Blues',
           marker="o")
ax.axis('scaled')  # {equal, scaled}
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.set_title('feature visulization')
ax.axis('off')          # 设置坐标轴不可见
ax.grid(False)          # 设置背景网格不可见

plt.show()
### 分割结果可视化

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np

points = np.loadtxt('data_part.txt')
skip = 5   # Skip every n points

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
point_range = range(0, points.shape[0], skip) # skip points to prevent crash
x = points[point_range, 0]
z = points[point_range, 1]
y = points[point_range, 2]
map_color = {35.0:'r', 32.0:'g', 31.0:'b', 33:'y'}
Label = points[point_range, -1]
Color = list(map(lambda  x: map_color[x], Label))

# map_maker = {-1:'o', 1:'v'}
# makers = list(map(lambda x:map_maker[x], Label))

ax.scatter(x,   # x
           y,   # y
           z,   # z
           c=Color, # height data for color
        #    cmap='Blues',
           marker="o")
ax.axis('scaled')  # {equal, scaled}
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.set_title('part_seg')
ax.axis('off')          # 设置坐标轴不可见
ax.grid(False)          # 设置背景网格不可见
plt.show()

参考:

  • 处理点云数据(三):三维点云可视化 https://blog.csdn.net/qq_33801763/article/details/78930167
  • python让scatter能够使不同类别的点有不同的颜色、大小和形状:https://blog.csdn.net/u014571489/article/details/102667570
  • python3D绘图Axes3D函数详解
  • PCL编程问题3:点云可视化 https://blog.csdn.net/lhy2677886724/article/details/88552494
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!